Created
May 4, 2011 16:22
-
-
Save haswalt/955509 to your computer and use it in GitHub Desktop.
Doctrine event listener
This file contains 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
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