public function testExceptionContainsDebuggingInfo()
 {
     $exception = MissingHandlerException::forCommand('League\\Tactician\\Tests\\Fixtures\\Command\\CompleteTaskCommand');
     $this->assertContains('League\\Tactician\\Tests\\Fixtures\\Command\\CompleteTaskCommand', $exception->getMessage());
     $this->assertSame('League\\Tactician\\Tests\\Fixtures\\Command\\CompleteTaskCommand', $exception->getCommandName());
     $this->assertInstanceOf('League\\Tactician\\Exception\\Exception', $exception);
 }
Example #2
0
 /**
  * Returns the handler bound to the command's class name.
  *
  * @param string $commandName
  *
  * @return object
  */
 public function getHandlerForCommand($commandName)
 {
     if (!isset($this->handlers[$commandName])) {
         throw MissingHandlerException::forCommand($commandName);
     }
     return $this->handlers[$commandName];
 }
 public function testExceptionContainsDebuggingInfo()
 {
     $exception = MissingHandlerException::forCommand(CompleteTaskCommand::class);
     $this->assertContains(CompleteTaskCommand::class, $exception->getMessage());
     $this->assertSame(CompleteTaskCommand::class, $exception->getCommandName());
     $this->assertInstanceOf(Exception::class, $exception);
 }
 /**
  * Retrieves the handler for a specified command
  *
  * @param string $commandName
  * @return mixed
  */
 public function getHandlerForCommand($commandName)
 {
     if (!isset($this->commandToServiceId[$commandName])) {
         throw MissingHandlerException::forCommand($commandName);
     }
     return $this->container->get($this->commandToServiceId[$commandName]);
 }
 /**
  * Returns the handler bound to the command's class name.
  *
  * @param  string  $command
  * @return object
  *
  * @throws \League\Tactician\Exception\MissingHandlerException
  */
 public function getHandlerForCommand($command)
 {
     $handlers = $this->config->get('tactician.handlers', []);
     if (!isset($handlers[$command]) || !class_exists($handlers[$command])) {
         throw MissingHandlerException::forCommand($command);
     }
     return $this->container->make($handlers[$command]);
 }
 /**
  * @param string $commandName
  *
  * @return mixed
  */
 public function getHandlerForCommand($commandName)
 {
     $handlerName = str_replace($this->origin, $this->target, $commandName);
     if (!class_exists($handlerName)) {
         throw MissingHandlerException::forCommand($commandName);
     }
     return $this->container->make($handlerName);
 }
Example #7
0
 /**
  * Retrieves the handler for a specified command
  *
  * @param string $commandName
  *
  * @throws MissingHandlerException
  * @return object
  */
 public function getHandlerForCommand($commandName)
 {
     $handler = $this->getHandlerClassName($commandName);
     if (!class_exists($handler)) {
         throw MissingHandlerException::forCommand($commandName);
     }
     return $this->container->make($handler);
 }
 /**
  * Retrieves the handler for a specified command
  *
  * @param string $commandName
  *
  * @return object
  *
  * @throws MissingHandlerException
  */
 public function getHandlerForCommand($commandName)
 {
     if (!isset($this->commandNameToHandlerMap[$commandName])) {
         throw MissingHandlerException::forCommand($commandName);
     }
     $serviceId = $this->commandNameToHandlerMap[$commandName];
     return $this->container->get($serviceId);
 }
 /**
  * Returns the handler located in the same directory for a specified command.
  *
  * @param  string  $command
  * @return object
  *
  * @throws \League\Tactician\Exception\MissingHandlerException
  */
 public function getHandlerForCommand($command)
 {
     $handler = substr_replace($command, 'CommandHandler', strrpos($command, 'Command'));
     if (!class_exists($handler)) {
         throw MissingHandlerException::forCommand($command);
     }
     return $this->container->make($handler);
 }
 /**
  * Retrieves the handler for a specified command
  *
  * @param string $commandName
  *
  * @return object
  *
  * @throws MissingHandlerException
  */
 public function getHandlerForCommand($commandName)
 {
     $handlerName = $commandName . 'Handler';
     if (!$this->serviceLocator->has($handlerName)) {
         throw MissingHandlerException::forCommand($commandName);
     }
     return $this->serviceLocator->get($handlerName);
 }
 /**
  * {@inheritdoc}
  */
 public function getHandlerForCommand($commandName)
 {
     $handlerId = 'app.command.' . str_replace('_command', '_handler', $commandName);
     try {
         return $this->container[$handlerId];
     } catch (\InvalidArgumentException $e) {
         throw MissingHandlerException::forCommand($commandName);
     }
 }
 /**
  * Returns the handler located in the configured namespace for given command.
  *
  * @param  string  $command
  * @return object
  *
  * @throws \League\Tactician\Exception\MissingHandlerException
  */
 public function getHandlerForCommand($command)
 {
     $namespaces = $this->config->get('tactician.namespaces', []);
     $handler = sprintf('%s\\%sHandler', $namespaces['handlers'], trim(str_ireplace($namespaces['commands'], '', $command), '\\'));
     if (!class_exists($handler)) {
         throw MissingHandlerException::forCommand($handler);
     }
     return $this->container->make($handler);
 }
Example #13
0
 /**
  * {@inheritdoc}
  */
 public function getHandlerForCommand($commandName)
 {
     $callable = $this->callable;
     $handler = $callable($commandName);
     // Odds are the callable threw an exception but it always pays to check
     if ($handler === null) {
         throw MissingHandlerException::forCommand($commandName);
     }
     return $handler;
 }
Example #14
0
 /**
  * Attempts to find the command's respective handler.
  *
  * @param  string $command_name
  *
  * @return mixed
  * 
  * @throws MissingHandlerException
  *
  */
 public function getHandlerForCommand($command_name)
 {
     $command = str_replace($this->command_namespace, '', $command_name);
     $handlerName = $this->handler_namespace . '\\' . trim($command, '\\') . 'Handler';
     if (!class_exists($handlerName)) {
         throw MissingHandlerException::forCommand($command_name);
     }
     $handler = $this->container->make($handlerName);
     return $handler;
 }