Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function locate($nameOfMessage)
 {
     if (!$this->handlers->containsKey($nameOfMessage)) {
         throw NotFoundException::handlerFor($nameOfMessage);
     }
     return $this->handlers->get($nameOfMessage);
 }
Ejemplo n.º 2
0
 /**
  * {@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);
 }
Ejemplo n.º 3
0
 /**
  * {@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);
 }
Ejemplo n.º 4
0
 /**
  * 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);
 }
Ejemplo n.º 5
0
 /**
  * Test methodForObject method.
  */
 public function testMethodForObject()
 {
     $this->given($exception = NotFoundException::methodForObject('foo', 'bar'))->then()->variable($exception->getPrevious())->isNull();
 }
Ejemplo n.º 6
0
 /**
  * @param MessageInterface $message
  *
  * @return NotFoundException
  */
 protected function notFoundException($message)
 {
     return NotFoundException::nameOfMessage($message);
 }
Ejemplo n.º 7
0
 /**
  * {@inheritdoc}
  */
 protected function notFoundException($query)
 {
     return NotFoundException::nameOfQuery($query);
 }
Ejemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 protected function notFoundException($command)
 {
     return NotFoundException::nameOfCommand($command);
 }