Пример #1
0
 /**
  * Outputs specified text to the console window
  * You can specify arguments that will be passed to the text via sprintf
  *
  * @see http://www.php.net/sprintf
  * @param string $text Text to output
  * @param array $arguments Optional arguments to use for sprintf
  * @return void
  */
 protected function output($text, array $arguments = array())
 {
     if ($arguments !== array()) {
         $text = vsprintf($text, $arguments);
     }
     $this->response->appendContent($text);
 }
 /**
  * Calls the specified command method and passes the arguments.
  *
  * If the command returns a string, it is appended to the content in the
  * response object. If the command doesn't return anything and a valid
  * view exists, the view is rendered automatically.
  *
  * @return void
  */
 protected function callCommandMethod()
 {
     $preparedArguments = array();
     /** @var Argument $argument */
     foreach ($this->arguments as $argument) {
         $preparedArguments[] = $argument->getValue();
     }
     $commandResult = call_user_func_array(array($this, $this->commandMethodName), $preparedArguments);
     if (is_string($commandResult) && strlen($commandResult) > 0) {
         $this->response->appendContent($commandResult);
     } elseif (is_object($commandResult) && method_exists($commandResult, '__toString')) {
         $this->response->appendContent((string) $commandResult);
     }
 }
Пример #3
0
 /**
  * Calls the specified command method and passes the arguments.
  *
  * If the command returns a string, it is appended to the content in the
  * response object. If the command doesn't return anything and a valid
  * view exists, the view is rendered automatically.
  *
  * @return void
  */
 protected function callCommandMethod()
 {
     $preparedArguments = [];
     /** @var Argument $argument */
     foreach ($this->arguments as $argument) {
         $preparedArguments[] = $argument->getValue();
     }
     $originalRole = $this->ensureAdminRoleIfRequested();
     $commandResult = call_user_func_array([$this, $this->commandMethodName], $preparedArguments);
     $this->restoreUserRole($originalRole);
     if (is_string($commandResult) && $commandResult !== '') {
         $this->response->appendContent($commandResult);
     } elseif (is_object($commandResult) && method_exists($commandResult, '__toString')) {
         $this->response->appendContent((string) $commandResult);
     }
 }