/** * Checks if a responder is defined for an action * * @param string $actionClass The full action class name * * @return bool */ public function hasResponder($actionClass) { $type = Type::create($actionClass)->toString(); if (!isset($this->responders[$type])) { return false; } $serviceId = $this->responders[$type]; return $this->container->has($serviceId); }
/** * Checks if a handler is defined for a command * * @param string $commandClass The full command class name * * @return bool */ public function hasHandler($commandClass) { $type = Type::create($commandClass)->toString(); if (!isset($this->handlers[$type])) { return false; } $serviceId = $this->handlers[$type]; return $this->container->has($serviceId); }
/** * Lazy loads event handlers from the service container * * @param string $eventType The event type * * @return void */ protected function lazyLoad($eventType) { if (isset($this->serviceIds[$eventType])) { foreach ($this->serviceIds[$eventType] as $args) { list($serviceId, $method, $priority) = $args; $service = $this->container->get($serviceId); $key = $serviceId . '.' . $method; if (!isset($this->services[$eventType][$key])) { $this->addHandler($eventType, [$service, $method], $priority); } elseif ($service !== $this->services[$eventType][$key]) { parent::removeHandler($eventType, [$this->services[$eventType][$key], $method]); $this->addHandler($eventType, [$service, $method], $priority); } $this->services[$eventType][$key] = $service; } } }