/** * Loads service from DI container * Triggers the listeners of an event. * * This method can be overridden to add functionality that is executed * for each listener. * * @param array[callback] $listeners The event listeners. * @param string $eventName The name of the event to dispatch. * @param Event $event The event object to pass to the event handlers/listeners. */ protected function doDispatch($listeners, $eventName, Event $event) { foreach ($listeners as $listenerParams) { $subscriber = $listenerParams[0]; $method = $listenerParams[1]; $service = $subscriber; if (is_string($subscriber)) { $service = $this->container->getService($subscriber); } $listener = [$service, $method]; call_user_func($listener, $event); if ($event->isPropagationStopped()) { break; } } }
/** * @param $presenter * @return string */ public function formatPresenterFile($presenter) { $service = $this->formatPresenterFromServiceName($presenter); if ($this->container->hasService($service)) { return get_class($this->container->getService($service)); } return parent::formatPresenterFile($presenter); }
/** * @deprecated */ public function getService($name) { trigger_error(__METHOD__ . '() is deprecated; use dependency injection instead.', E_USER_DEPRECATED); return $this->context->getService($name); }
/** * @deprecated */ public final function getService($name) { return $this->context->getService($name); }
function __construct(SystemContainer $container) { $this->container = $container; $this->user = $container->getService('user'); $this->parameters = $container->parameters; }