Skip to content

Instantly share code, notes, and snippets.

@ger86
Created February 8, 2019 13:23
Show Gist options
  • Save ger86/5d6b2a58433ba4da007e329900bea748 to your computer and use it in GitHub Desktop.
Save ger86/5d6b2a58433ba4da007e329900bea748 to your computer and use it in GitHub Desktop.
<?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