diff --git a/adr/004-m2m-audit-logging-join-table-query.md b/adr/004-m2m-audit-logging-join-table-query.md index 426be6229..c46c607f8 100644 --- a/adr/004-m2m-audit-logging-join-table-query.md +++ b/adr/004-m2m-audit-logging-join-table-query.md @@ -414,26 +414,14 @@ case IAuditStrategy::EVENT_COLLECTION_MANYTOMANY_DELETE: To add M2M audit support for a new entity: -1. Add a combined `EVENT_COLLECTION_MANYTOMANY_UPDATE`/`DELETE` case to the entity's formatter's `switch`: +1. Add a combined `EVENT_COLLECTION_MANYTOMANY_UPDATE`/`DELETE` case to the entity's formatter's `switch`, routing both events to the shared base method with the entity wording as the label: ```php case IAuditStrategy::EVENT_COLLECTION_MANYTOMANY_UPDATE: case IAuditStrategy::EVENT_COLLECTION_MANYTOMANY_DELETE: - return $this->handleEntityManyToManyCollection($change_set, $id, $name); + return $this->formatManyToManyCollectionChange($change_set, sprintf("Entity '%s' (%s)", $name, $id)); ``` -2. Implement the private handler following the two-step pattern: - ```php - private function handleEntityManyToManyCollection(array $change_set, $id, $name): ?string - { - $metadata = $this->handleManyToManyCollection($change_set); - if (!$metadata) return null; - $collectionData = $this->processCollection($metadata); - if (!$collectionData) return null; - return $this->event_type === IAuditStrategy::EVENT_COLLECTION_MANYTOMANY_DELETE - ? $this->formatManyToManyDelete($collectionData, $id, $name) - : $this->formatManyToManyUpdate($collectionData, $id, $name); - } - ``` -3. Implement private `formatManyToManyUpdate()` and `formatManyToManyDelete()` with entity-specific message formatting. +2. Nothing else is needed in the formatter. `AbstractAuditLogFormatter::formatManyToManyCollectionChange(array $change_set, string $label): ?string` runs the two-step pipeline (`handleManyToManyCollection()` then `processCollection()`), picks update or delete from `$this->event_type`, and builds the message `