Created
June 17, 2014 10:05
-
-
Save mrcmorales/dd49e9c83c7d5b2810b2 to your computer and use it in GitHub Desktop.
doctrine listener
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
class WouzeeEventListener | |
{ | |
protected $eventDispatcher; | |
public function __construct(EventDispatcherInterface $eventDispatcher) | |
{ | |
$this->eventDispatcher = $eventDispatcher; | |
} | |
public function getSubscribedEvents() | |
{ | |
return array( | |
'postPersist', | |
'postFlush', | |
); | |
} | |
public function postPersist(EventArgs $args) | |
{ | |
$entity = $args->getEntity; | |
if ($entity instanceof WouzeeEvent) { | |
$event = new GenericEvent($entity, array('type' => RabbitActionEnum::NEW_EVENT)); | |
$this->dispatchEvent($event); | |
} | |
} | |
public function postFlush(PostFlushEventArgs $args) | |
{ | |
$entity = $args->getEntity(); | |
if ($entity instanceof WouzeeEvent) { | |
var_dump('entra post flush'); | |
} | |
} | |
private function dispatchEvent(GenericEvent $event) | |
{ | |
$this->eventDispatcher->dispatch(WouzeeEventEnum::NEW_EVENT, $event); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment