/** * Gets named guard object * * @param string $name * @return GuardInterface */ public function getGuard($name) { if (!($guard = $this->container->has($name))) { $message = sprintf('"%s" guard is not found in DI container', $name); throw new Exception\GuardNotFoundException($message); } $guard = $this->container->get($name); if (!$guard instanceof GuardInterface) { $message = sprintf('Guard "%s" must be object and instance of GuardInterface', is_object($guard) ? get_class($guard) : gettype($guard)); throw new Exception\InvalidGuardException($message); } return $guard; }
/** * Gets named listener object * * @param string $name * @return ListenerInterface */ public function getListener($name) { if (!$this->container->has($name)) { $message = sprintf('"%s" listener is not found in DI container', $name); throw new Exception\ListenerNotFoundException($message); } $listener = $this->container->get($name); if (!$listener instanceof ListenerInterface) { $message = sprintf('Listener "%s" must be object and instance of ListenerInterface', is_object($listener) ? get_class($listener) : gettype($listener)); throw new Exception\InvalidListenerException($message); } return $listener; }