public function dispatch($eventName, Event $event = null)
 {
     if (null === $event) {
         $event = new Event();
     }
     parent::dispatch($eventName, $event);
     $silexEvent = $this->getProxyMapper()->createProxyEvent($event);
     if ($silexEvent) {
         $this->eventManager->trigger($silexEvent);
     }
     return $event;
 }
Esempio n. 2
0
 /**
  * @return EventManagerInterface
  */
 public function getEventManager()
 {
     if (!$this->eventManager) {
         $this->eventManager = new EventManager();
         $this->eventManager->setLogger($this->getLogger());
         $this->eventManager->addListener(new DefaultProxyListener($this->getFirewall()))->addListener(new ProxyCacheListener($this->getCacheStrategy(), $this->getStorage()));
     }
     return $this->eventManager;
 }
Esempio n. 3
0
 /**
  * Calls given proxy event
  * Throws an exception if event was cancelled
  *
  * @param ProxyEventInterface $event
  */
 private function callProxyEvent(ProxyEventInterface $event)
 {
     if ($event instanceof LoggerAwareInterface) {
         $event->setLogger($this->logger);
     }
     $this->eventManager->trigger($event);
     if ($event instanceof CancellableEventInterface && $event->isCancelled()) {
         throw new CancelledEventException($event);
     }
 }