execute() public method

命令角色
public execute ( )
Exemplo n.º 1
0
 /**
  * @param  Context $context
  * @return boolean
  **/
 public function execute(Context $context)
 {
     if ($context->getCurrentCommand() != 'begin') {
         throw new \Exception('構文が正しくありません');
     }
     if (is_null($this->next_command)) {
         throw new \Exception('次のコマンドが指定されていません');
     }
     $this->next_command->execute($context->next());
     return true;
 }
Exemplo n.º 2
0
 /**
  * Test that the default value is overwritten when the parameter
  * 	is defined.
  */
 public function testParseDefaultValueIsDefined()
 {
     $config = ['default' => ['test' => 'testing1234']];
     $arguments = ['script-name.php', '--test=foobar'];
     $cmd = new Command();
     $result = $cmd->execute($arguments, $config);
     $this->assertEquals('foobar', $result['test']);
 }
Exemplo n.º 3
0
 /**
  * 编辑md文件 /docx/usage/start.md
  * @param $file
  * @param $route
  * @throws Exception
  */
 public function actionEditMarkdown($file, $route)
 {
     $title = DirectoryIndex::trimFileExtension(basename($file));
     if (!is_file($file)) {
         $cmd[] = sprintf("mkdir -p %s", dirname($file));
         $cmd[] = sprintf("echo '# %s%s-------------' > %s", $title, PHP_EOL, $file);
         $command = join(" && ", $cmd);
         $ret = Command::execute($command);
     }
     $content = file_get_contents($file);
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $content = $_POST['content'];
         $ret = file_put_contents($file, $content);
         $htmlFile = static::md2HtmlFile($route);
         $url = sprintf("/%s?action=%s", $htmlFile, static::PUSH_GIT_URL);
         $this->redirect($url);
     }
     $time = time();
     $this->render(static::VIEW_EDITOR, ['timestamp' => $time, 'token' => md5($this->_config['validationKey'] . $time), 'returnUrl' => DirectoryIndex::file2Url($file), 'title' => $title, 'content' => $content]);
 }
Exemplo n.º 4
0
 /**
  * Run a command that will talk to the transport
  *
  * @param Command $command
  * @return mixed
  */
 protected function runCommand(Command $command)
 {
     $result = $command->execute();
     return $result;
 }
Exemplo n.º 5
0
 /**
  * Run a command that will talk to the connection
  *
  * @param Command $command
  * @return boolean
  */
 public function execCommand(Command $command)
 {
     return $command->execute($this);
 }
Exemplo n.º 6
0
    Utils::redirect('login.php');
}
$actualUrl = Utils::getActualUrl();
$room = intval($_GET['id']);
if (!$room) {
    Utils::redirect('rooms.php');
}
Room::addUser($loggedUser['id'], $room);
$gameRepository = new GameRepository();
$game = $gameRepository->getOneByRoom($room);
if ($game) {
    $GLOBALS['smarty']->assign('game', $game);
}
if ($_POST && trim($_POST['message'])) {
    if (strpos($_POST['message'], '.') === 0) {
        $commandResult = Command::execute($_POST['message'], $game);
    } else {
        Chat::addMessage(trim($_POST['message']), $room);
    }
    Room::updateUserLastActivity($loggedUser['id'], $room);
    Utils::redirect($actualUrl);
}
$messages = Chat::getMessages($room, $loggedUser['id']);
$emoticons = Emoticons::getEmoticons();
$GLOBALS['smarty']->assign('loggedUser', $loggedUser);
$GLOBALS['smarty']->assign('room', $room);
$GLOBALS['smarty']->assign('messages', $messages);
$GLOBALS['smarty']->assign('users', Room::getUsers($room));
$GLOBALS['smarty']->assign('emoticonDir', EMOTICONS_DIR);
$GLOBALS['smarty']->assign('emoticons', $emoticons);
$GLOBALS['smarty']->assign('content', $GLOBALS['smarty']->fetch('room.tpl'));
Exemplo n.º 7
0
 public function storeAndExecute(Command $cmd)
 {
     $this->history[] = $cmd;
     // optional
     return $cmd->execute();
 }
Exemplo n.º 8
0
 /**
  *
  */
 public static function commandAction()
 {
     if ($bundles = self::getBundles()) {
         foreach ($bundles as $name => $path) {
             $command_path = $path . '/command';
             if (is_dir($command_path)) {
                 if ($dh = opendir($command_path)) {
                     while (($file = readdir($dh)) !== false) {
                         if ($file != "." && $file != ".." && preg_match("/\\.php\$/", $file)) {
                             require_once $command_path . '/' . $file;
                             $command_name = pathinfo($file, PATHINFO_FILENAME);
                             CommandController::add($command_name);
                         }
                     }
                     closedir($dh);
                 }
             }
         }
     }
     Command::execute();
 }
Exemplo n.º 9
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     parent::execute($input, $output);
     $jwks_file = $input->getArgument('jwks_file');
     if (!file_exists($jwks_file)) {
         $output->writeln('File not found: ' . $jwks_file);
         return 1;
     }
     $set = $this->loadKeySet(file_get_contents($jwks_file));
     $table = new Table($output);
     $table->setStyle('borderless');
     $table->setHeaders(array('ID', 'Type', 'Size', 'Use', 'Ops'));
     foreach ($set->getKeys() as $key) {
         $id = $key->getKeyId();
         if (strlen($id) > 7) {
             $id = substr($id, 0, 7) . '...';
         }
         $kty = $key->getKeyType();
         if (!$key->isPublic()) {
             $kty .= '*';
         }
         $size = $key->getSize();
         $use = $key->getUse();
         if ($use == null) {
             $use = '';
         }
         $ops = $key->getOperations();
         if ($ops == null) {
             $ops = array();
         }
         $ops = implode(',', $ops);
         $table->addRow(array($id, $kty, $size, $use, $ops));
     }
     $table->render();
 }