Skip to content

Instantly share code, notes, and snippets.

@haswalt
Created May 4, 2011 16:22
Show Gist options
  • Save haswalt/955509 to your computer and use it in GitHub Desktop.
Save haswalt/955509 to your computer and use it in GitHub Desktop.
Doctrine event listener
public function getSubscribedEvents()
{
return array(Events::postPersist);
}
public function postPersist(LifecycleEventArgs $args)
{
$em = $args->getEntityManager();
$uow = $em->getUnitOfWork();
foreach ($uow->getScheduledEntityInsertions() as $entity) {
if ($entity instanceof Searchable) {
//echo $entity->getModel();
$data = $entity->getDataForSearch();
// always add id to data
var_dump($uow->getEntityIdentifier($entity));
var_dump($data);
exit;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment