Esempio n. 1
0
 /**
  * Retrieves a handler by query class name
  *
  * @param string $queryClass The full query class name
  *
  * @return QueryHandler
  *
  * @throws HandlerNotFoundException When the handler is not found
  */
 public function getHandler($queryClass)
 {
     $type = Type::create($queryClass)->toString();
     if (!isset($this->handlers[$type])) {
         $message = sprintf('Handler not defined for query: %s', $queryClass);
         throw HandlerNotFoundException::create($message);
     }
     return $this->handlers[$type];
 }
Esempio n. 2
0
 /**
  * Retrieves a handler by query class name
  *
  * @param string $queryClass The full query class name
  *
  * @return QueryHandler
  *
  * @throws HandlerNotFoundException When the handler is not found
  */
 public function getHandler($queryClass)
 {
     $type = Type::create($queryClass)->toString();
     if (!isset($this->handlers[$type])) {
         $message = sprintf('Handler not defined for query: %s', $queryClass);
         throw HandlerNotFoundException::create($message);
     }
     $serviceId = $this->handlers[$type];
     try {
         $handler = $this->container->get($serviceId);
     } catch (ServiceContainerException $exception) {
         throw HandlerNotFoundException::create($exception->getMessage(), $exception);
     }
     return $handler;
 }
 public function test_that_create_returns_exception_instance()
 {
     $exception = HandlerNotFoundException::create('Handler not found');
     $this->assertInstanceOf('Novuso\\Common\\Application\\Messaging\\Query\\Exception\\HandlerNotFoundException', $exception);
 }