Example #1
0
 /**
  * @return array|callable[]
  */
 public function getListeners()
 {
     $listeners = $this->listeners;
     if ($this->panel) {
         $this->panel->inlineCallbacks($this->getName(), $listeners);
     } elseif (!$this->eventManager || !$this->eventManager->hasListeners($this->getName())) {
         return $listeners;
     }
     $name = $this->getName();
     $evm = $this->eventManager;
     $argsClass = $this->argsClass;
     $globalDispatch = function () use($name, $evm, $argsClass) {
         if ($argsClass === NULL) {
             $args = new EventArgsList(func_get_args());
         } else {
             $args = Nette\Reflection\ClassType::from($argsClass)->newInstanceArgs(func_get_args());
         }
         $evm->dispatchEvent($name, $args);
     };
     if ($this->globalDispatchFirst) {
         array_unshift($listeners, $globalDispatch);
     } else {
         $listeners[] = $globalDispatch;
     }
     return $listeners;
 }
Example #2
0
 /**
  * @param string|array $name
  * @param array $defaults
  * @param string $argsClass
  * @return Event
  */
 public function createEvent($name, $defaults = array(), $argsClass = NULL)
 {
     $event = new Event($name, $defaults, $argsClass);
     $event->injectEventManager($this);
     if ($this->panel) {
         $this->panel->registerEvent($event);
     }
     return $event;
 }
 /**
  * @param string|array $name
  * @param array $defaults
  * @param string $argsClass
  * @param bool $globalDispatchFirst
  * @return Event
  */
 public function createEvent($name, $defaults = array(), $argsClass = NULL, $globalDispatchFirst = FALSE)
 {
     $event = new Event($name, $defaults, $argsClass);
     $event->globalDispatchFirst = $globalDispatchFirst;
     $event->injectEventManager($this);
     if ($this->panel) {
         $this->panel->registerEvent($event);
     }
     return $event;
 }