/** * {@inheritdoc} */ public function locate($nameOfMessage) { if (!$this->handlers->containsKey($nameOfMessage)) { throw NotFoundException::handlerFor($nameOfMessage); } return $this->handlers->get($nameOfMessage); }
/** * {@inheritdoc} */ public function resolve(MessageInterface $message) { $nameOfMessage = $this->nameOfMessageResolver->resolve($message); $handler = $this->getHandlerFor($nameOfMessage); $handlerMethodName = $this->getHandlerMethodFor($nameOfMessage); if (!method_exists($handler, $handlerMethodName)) { throw NotFoundException::methodForObject($handler, $handlerMethodName); } return Delegate::fromMethod($handler, $handlerMethodName); }
/** * {@inheritdoc} */ public function resolve($className) { foreach ($this->resolvers as $resolver) { try { /* @var ResolverInterface $resolver */ return $resolver->resolve($className); } catch (\Exception $exception) { } } throw NotFoundException::handlerMethodNameForObject($className); }
/** * Ensure that exists an dispatcher middleware. * * @throws InvalidArgumentException */ protected function ensureEventDispatcherMiddleware() { if ($this->dispatcherMiddleware !== null) { return; } foreach ($this->middlewares as $priority => $collection) { foreach ($collection as $middleware) { if ($middleware instanceof EventDispatcherMiddleware) { $this->dispatcherMiddleware = $middleware; return; } } } throw NotFoundException::middlewareOfType(EventDispatcherMiddleware::class); }
/** * Test methodForObject method. */ public function testMethodForObject() { $this->given($exception = NotFoundException::methodForObject('foo', 'bar'))->then()->variable($exception->getPrevious())->isNull(); }
/** * @param MessageInterface $message * * @return NotFoundException */ protected function notFoundException($message) { return NotFoundException::nameOfMessage($message); }
/** * {@inheritdoc} */ protected function notFoundException($query) { return NotFoundException::nameOfQuery($query); }
/** * {@inheritdoc} */ protected function notFoundException($command) { return NotFoundException::nameOfCommand($command); }