Created
February 8, 2019 13:23
-
-
Save ger86/5d6b2a58433ba4da007e329900bea748 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Doctrine\EntityListener; | |
| use Doctrine\ORM\EntityManagerInterface; | |
| use Doctrine\ORM\Event\OnFlushEventArgs; | |
| use App\Entity\Post; | |
| class PostEntityListener { | |
| /** | |
| * @inheritDoc | |
| * @param OnFlushEventArgs $event | |
| * @return void | |
| */ | |
| public function onFlush(OnFlushEventArgs $event) { | |
| $em = $event->getEntityManager(); | |
| $uow = $em->getUnitOfWork(); | |
| foreach ($uow->getScheduledCollectionUpdates() as $collection) { | |
| $entity = $collection->getOwner(); | |
| if ($entity instanceof Post) { | |
| // next step | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment