private function triggerEvent(OW_Event $event) { if (in_array($event->getName(), $this->disabledEvents)) { return $event; } return OW::getEventManager()->trigger($event); }
/** * Calls last event listener and returns it's result value. * * @param string $eventName * @param array $eventParams * @return mixed */ public function call($eventName, $eventParams = array()) { $event = new OW_Event($eventName, $eventParams); if (!empty($this->listeners[$eventName])) { ksort($this->listeners[$event->getName()]); // log triggered events for developer mode if ($this->devMode) { $startTime = UTIL_Profiler::getInstance()->getTotalTime(); $this->profiler->reset(); $handlers = reset($this->listeners[$eventName]); $result = call_user_func(end($handlers), $event); if (!in_array($event->getName(), $this->eventsToSkip) && count($this->eventsLog) < $this->maxItemsInLog) { $this->eventsLog[] = array('type' => 'call', 'start' => $startTime, 'exec' => $this->profiler->getTotalTime(), 'event' => $event, 'listeners' => $this->listeners[$event->getName()]); } } else { $handlers = reset($this->listeners[$eventName]); $result = call_user_func(end($handlers), $event); } return $result; } else { // log events with no listeners $startTime = UTIL_Profiler::getInstance()->getTotalTime(); if ($this->devMode && !in_array($event->getName(), $this->eventsToSkip) && count($this->eventsLog) < $this->maxItemsInLog) { $this->eventsLog[] = array('type' => 'call', 'start' => $startTime, 'event' => $event, 'listeners' => array(), 'exec' => 0); } } }