Get scheduled extra updates from Doctrine UnitOfWork Get scheduled extra updates from Doctrine UnitOfWork symfony symfony

Get scheduled extra updates from Doctrine UnitOfWork


So, the detailed answer for this question would be something like this:

Listen to the preSoftDelete event (Symfony2 DoctrineExtensions preSoftDelete event call):

    tags:        - { name: doctrine.event_listener, event: preSoftDelete }

Then in your listener class, add the following method:

public function preSoftDelete(LifecycleEventArgs $args){    $entity = $args->getEntity();    $em = $args->getEntityManager();    if ($entity instanceof ETaggableInterface || $entity instanceof ETagRelatedInterface) {        $entity->updateEtag('foo'); // Was not clear what $this->updateEtag() do        $em->persist($entity);        $classMetadata = $em->getClassMetadata(get_class($entity));        $em->getUnitOfWork()->computeChangeSet($classMetadata, $entity);    }}

This will update the entity, tell to persist it, calculate the changes.