refactor(audit) : update audit subscribers to use ConstructeurLinks
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,6 @@ use Doctrine\Common\EventSubscriber;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Event\OnFlushEventArgs;
|
||||
use Doctrine\ORM\Events;
|
||||
use Doctrine\ORM\PersistentCollection;
|
||||
use Doctrine\ORM\UnitOfWork;
|
||||
use Error;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
@@ -88,8 +87,7 @@ abstract class AbstractAuditSubscriber implements EventSubscriber
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this subscriber tracks constructeur collection changes.
|
||||
* Override to return true for entities with a constructeurs ManyToMany.
|
||||
* Whether this subscriber uses the complex onFlush path (collection + custom field tracking).
|
||||
*/
|
||||
protected function hasCollectionTracking(): bool
|
||||
{
|
||||
@@ -413,50 +411,16 @@ abstract class AbstractAuditSubscriber implements EventSubscriber
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op: constructeurs are now tracked as ConstructeurLink entities (OneToMany),
|
||||
* so Doctrine no longer fires collection update events for them.
|
||||
*/
|
||||
private function collectCollectionUpdate(
|
||||
object $collection,
|
||||
array &$pendingUpdates,
|
||||
array &$pendingSnapshots,
|
||||
array &$pendingEntities,
|
||||
): void {
|
||||
if (!$collection instanceof PersistentCollection) {
|
||||
return;
|
||||
}
|
||||
|
||||
$owner = $collection->getOwner();
|
||||
if (null === $owner || !$this->supports($owner)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$ownerId = (string) $owner->getId();
|
||||
if ('' === $ownerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$mapping = $collection->getMapping();
|
||||
$fieldName = $mapping['fieldName'] ?? null;
|
||||
if ('constructeurs' !== $fieldName) {
|
||||
return;
|
||||
}
|
||||
|
||||
$before = $this->normalizeCollection($collection->getSnapshot());
|
||||
$after = $this->normalizeCollection($collection->toArray());
|
||||
|
||||
if ($before === $after) {
|
||||
return;
|
||||
}
|
||||
|
||||
$diff = [
|
||||
'constructeurIds' => [
|
||||
'from' => $before,
|
||||
'to' => $after,
|
||||
],
|
||||
];
|
||||
|
||||
$pendingUpdates[$ownerId] = $this->mergeDiffs($pendingUpdates[$ownerId] ?? [], $diff);
|
||||
$pendingSnapshots[$ownerId] = $this->snapshotEntity($owner);
|
||||
$pendingEntities[$ownerId] = $owner;
|
||||
}
|
||||
): void {}
|
||||
|
||||
private function collectCustomFieldValueChanges(
|
||||
UnitOfWork $uow,
|
||||
|
||||
Reference in New Issue
Block a user