public static function newFromCommandException(CommandException $ex)
 {
     $error = new self();
     $error->command = (string) $ex->getCommand();
     $error->error = $ex->getError();
     $error->stdout = $ex->getStdout();
     $error->stderr = $ex->getStderr();
     return $error;
 }
 /**
  * get command handler
  *
  * @param string $alias
  * @throws CommandException
  * @return callable
  */
 public function getCommandHandler($alias)
 {
     if (class_exists($alias)) {
         return new $alias();
     }
     throw CommandException::handlerError(sprintf('alias <%s> does not exist', $alias));
 }
Beispiel #3
0
 /**
  * Check that the given options contain all required keys.
  *
  * @param array $options
  * @param array $keys
  *
  * @return void
  *
  * @throws CommandException
  *  If any required options are missing.
  */
 private function checkRequired(array $options, array $keys)
 {
     $missing = array_keys(array_diff_key(array_flip($keys), $options));
     if (!empty($missing)) {
         throw CommandException::missingOptions($missing);
     }
 }
Beispiel #4
0
 /**
  * @inheritDoc
  *
  * @return array
  */
 public function options()
 {
     $required = $this->requiredOptions();
     if ($required) {
         $missing = array_diff($required, array_keys($this->options));
         if ($missing) {
             throw CommandException::missingOptions($missing);
         }
     }
     $this->options += $this->defaultOptions();
     return $this->options;
 }
 /**
  * Overwrites parent constructor to be able to inject matching commands.
  *
  * @param string $message
  * @param integer $code
  * @param \Exception $previousException
  * @param array<\TYPO3\FLOW3\Cli\Command> $matchingCommands Commands that matched the command identifier
  * @see \Exception
  */
 public function __construct($message = '', $code = 0, \Exception $previousException = NULL, array $matchingCommands)
 {
     $this->matchingCommands = $matchingCommands;
     parent::__construct($message, $code, $previousException);
 }
 protected function setWorkingCopyVCSErrorFromCommandException(DrydockLease $lease, $phase, $command, CommandException $ex)
 {
     $error = array('phase' => $phase, 'command' => (string) $command, 'raw' => (string) $ex->getCommand(), 'err' => $ex->getError(), 'stdout' => $ex->getStdout(), 'stderr' => $ex->getStderr());
     $lease->setAttribute('workingcopy.vcs.error', $error);
 }
 public function __construct($message, $code = 0)
 {
     parent::__construct($message, $code);
 }
 public static function newFromCommandException($phase, $command, CommandException $ex)
 {
     $error = array('phase' => $phase, 'command' => (string) $command, 'raw' => (string) $ex->getCommand(), 'err' => $ex->getError(), 'stdout' => $ex->getStdout(), 'stderr' => $ex->getStderr());
     return $error;
 }