Listener/TaggedEntityListener.php
public function onFlush(OnFlushEventArgs $eventArgs)
    {
        $em = $eventArgs->getEntityManager();
        $uow = $em->getUnitOfWork();

        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            $this->invalidateEntity($entity);
        }

        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            $this->invalidateEntity($entity);
        }

        foreach ($uow->getScheduledEntityDeletions() as $entity) {
            $this->invalidateEntity($entity);
        }

        /** @var \Doctrine\Common\Collections\ArrayCollection $col */
        foreach ($uow->getScheduledCollectionUpdates() as $col) {
            foreach ($col as $entity) {
                $this->invalidateEntity($entity);
            }
        }

        foreach ($uow->getScheduledCollectionDeletions() as $col) {
            foreach ($col as $entity) {
                $this->invalidateEntity($entity);
            }
        }
    }
public function onFlush(OnFlushEventArgs $eventArgs)
    {
        $em = $eventArgs->getEntityManager();
        $uow = $em->getUnitOfWork();

        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            $this->invalidateEntity($entity);
        }

        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            $this->invalidateEntity($entity);
        }

        foreach ($uow->getScheduledEntityDeletions() as $entity) {
            $this->invalidateEntity($entity);
        }

        /** @var \Doctrine\Common\Collections\ArrayCollection $col */
        foreach ($uow->getScheduledCollectionUpdates() as $col) {
            foreach ($col as $entity) {
                $this->invalidateEntity($entity);
            }
        }

        foreach ($uow->getScheduledCollectionDeletions() as $col) {
            foreach ($col as $entity) {
                $this->invalidateEntity($entity);
            }
        }
    }
On flush event handler.

@param OnFlushEventArgs $eventArgs