/** * Dispatch event to all listener subscribed * * @param mixed $event * @param mixed|array $parameters * @return BaseEvent mixed */ public function dispatchEvent($event, $parameters = array()) { if (is_string($event)) { $event = new BaseEvent($event, $parameters); } $eventName = $event->getName(); $event->setDispatcher($this); if ($this->hasListeners($eventName)) { foreach ($this->_listeners[$eventName] as $priority => $listeners) { foreach ($listeners as $listener) { if ($event->isPropagationStopped($priority)) { break; } call_user_func($listener, $event); } } } return $event; }