예제 #1
0
 public function dispatch($event, $context = null)
 {
     if (!$event instanceof Event) {
         $event = new Event(strval($event), $context);
     }
     if ($context) {
         $event->setContext($context);
     }
     if ($this->delegateDispatcher instanceof EventDispatcherInterface) {
         $this->delegateDispatcher->dispatch($event);
         return;
     }
     /** @noinspection PhpParamsInspection */
     $event->setTarget($this);
     $chain = [];
     /** @var EventDispatcherInterface $dispatcher */
     $dispatcher = $this;
     do {
         $chain[] = $dispatcher;
     } while ($dispatcher = $dispatcher->getParentEventDispatcher());
     if (!$event->doesBubble()) {
         // this event uses capturing method
         $chain = array_reverse($chain);
     }
     foreach ($chain as $dispatcher) {
         /** @noinspection PhpUndefinedMethodInspection */
         $dispatcher->doDispatchEvent($event);
         if ($event->isPropogationStopped()) {
             break;
         }
     }
 }
예제 #2
0
 /**
  * @return void
  */
 public function shutdown()
 {
     if (!$this->booted) {
         return;
     }
     $this->dispatcher->dispatch(KernelEvents::BEFORE_MODULES_SHUTDOWN, $this->kernelEvent);
     foreach ($this->modules as $module) {
         $module->shutdown($this);
     }
     $this->dispatcher->dispatch(KernelEvents::AFTER_MODULES_SHUTDOWN, $this->kernelEvent);
 }
 /**
  * Registers an onCoreException listener.
  *
  * @param EventDispatcher $dispatcher An EventDispatcher instance
  * @param integer         $priority   The priority
  */
 public function register(EventDispatcherInterface $dispatcher)
 {
     $dispatcher->addListener(Events::onCoreException, $this);
 }
예제 #4
0
 /**
  *
  * {@inheritdoc}
  *
  */
 public function hasListeners($eventName = null)
 {
     return $this->dispatcher->hasListeners($eventName);
 }
 /**
  * {@inheritdoc}
  */
 public function getListeners($event = null)
 {
     return $this->events->getListeners($event);
 }
 public function dispatchEvent(EventInterface $event)
 {
     $this->eventDispatcher->dispatchEvent($event);
 }
예제 #7
0
 /**
  * {@inheritdoc}
  */
 public function getEventClass()
 {
     return $this->events->getEventClass();
 }