public static function getSubscribedEvents(): array
{ return [ PreWriteValidationEvent::
class => 'triggerChangeSet',
EntityWrittenContainerEvent::
class => 'onEntityWritten',
];
} public function triggerChangeSet(PreWriteValidationEvent
$event): void
{ $associatedEntities =
$this->
getAssociationEntities();
foreach ($event->
getCommands() as $command) { $definition =
$command->
getDefinition();
$entity =
$definition->
getEntityName();
if (!
$command instanceof ChangeSetAware || !\
in_array($entity,
$associatedEntities, true
)) { continue;
} if ($command instanceof DeleteCommand
) { $command->
requestChangeSet();