• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Command类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Command的典型用法代码示例。如果您正苦于以下问题:PHP Command类的具体用法?PHP Command怎么用?PHP Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Command类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: invokeCallbacks

 /**
  * Invoke a command by calling all the registered callbacks
  *
  * @param  string|CommandInterface  $command    The command name or a CommandInterface object
  * @param  array|\Traversable       $attributes An associative array or a Traversable object
  * @param  ObjectInterface          $subject    The command subject
  * @return mixed|null If a callback break, returns the break condition. NULL otherwise.
  */
 public function invokeCallbacks($command, $attributes = null, $subject = null)
 {
     //Make sure we have an command object
     if (!$command instanceof CommandInterface) {
         if ($attributes instanceof CommandInterface) {
             $name = $command;
             $command = $attributes;
             $command->setName($name);
         } else {
             $command = new Command($command, $attributes, $subject);
         }
     }
     foreach ($this->getCommandCallbacks($command->getName()) as $handler) {
         $method = $handler['method'];
         $params = $handler['params'];
         if (is_string($method)) {
             $result = $this->invokeCommandCallback($method, $command->append($params));
         } else {
             $result = $method($command->append($params));
         }
         if ($result !== null && $result === $this->getBreakCondition()) {
             return $result;
         }
     }
 }
开发者ID:nooku,项目名称:nooku-framework,代码行数:33,代码来源:abstract.php


示例2: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if (strtolower($command->getName()) == "popup") {
         if ($sender->hasPermission("joinpopup") || $sender->hasPermission("joinpopup.command")) {
             if (isset($args[0]) == "off") {
                 if (isset($this->playersEnabled[$sender->getName()])) {
                     unset($this->playersEnabled[$sender->getName()]);
                     $sender->sendMessage("Popups disabled");
                     return true;
                 } else {
                     $sender->sendMessage("Popups aren't enabled for you");
                     return true;
                 }
             } elseif ($args[0] == "on") {
                 if (isset($this->playersEnabled[$sender->getName()])) {
                     $sender->sendMessage("Popups are already enabled for you");
                     return true;
                 } else {
                     $this->playersEnabled[$sender->getName] = $sender->getName();
                     $sender->sendMessage("Popups has been enabled for you");
                     return true;
                 }
             } else {
                 $sender->sendMessage("Unknown argument: " . $args[0]);
                 return true;
             }
         } else {
             $sender->sendMessage("You don't have permission to use that command!");
             return true;
         }
     }
 }
开发者ID:Blubberboy333,项目名称:JoinPopups,代码行数:32,代码来源:Main.php


示例3: shellCommandString

 private static function shellCommandString($string)
 {
     $command = new Command();
     $command->configure($string);
     $shellCommand = new ShellCommand($command);
     return strval($shellCommand);
 }
开发者ID:lionjsa,项目名称:barberry-plugin-imagemagick,代码行数:7,代码来源:ShellCommandTest.php


示例4: handle

 public function handle(Command $command, ClientContext $context) : Generator
 {
     $article = (yield from $this->fetchArticleFromArgs($context, ...$command->args()));
     if ($article) {
         yield from $context->writeResponse(new Response(223, '%d %s Article exists', $article->number(), $article->id()));
     }
 }
开发者ID:coderstephen,项目名称:libnntp,代码行数:7,代码来源:StatHandler.php


示例5: generate

 /**
  * @param Command $command
  *
  * @return string
  */
 public function generate(Command $command)
 {
     $origMethodName = $command->getMethod() ?: $command->getName();
     $methodNameParts = explode('-', $origMethodName);
     $methodNameStart = array_shift($methodNameParts);
     $methodNameEnd = implode('', array_map('ucfirst', $methodNameParts));
     return $methodNameStart . $methodNameEnd . 'Cmd';
 }
开发者ID:alcaeus,项目名称:hipchat-commander,代码行数:13,代码来源:MethodGenerator.php


示例6: testParseDefaultValueIsDefined

 /**
  * 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']);
 }
开发者ID:Stunt,项目名称:cmd,代码行数:12,代码来源:CommandTest.php


示例7: add

 /**
  * Add a command to this collection.
  *
  * @param  Command $command  The command to add
  *
  * @return CommandCollection Returns $this for chainability
  *
  * @throws \InvalidArgumentException If a command with the same name has
  *                                   already been set on this collection
  */
 public function add(Command $command)
 {
     if (isset($this->_commands[$command->getName()])) {
         throw new \InvalidArgumentException(sprintf('Command `%s` is already defined', $command->getName()));
     }
     $this->_commands[$command->getName()] = $command;
     return $this;
 }
开发者ID:mothership-ec,项目名称:cog,代码行数:18,代码来源:CommandCollection.php


示例8: postCommandRun

 public function postCommandRun(Command $command, $method, $args)
 {
     $mode = Current::$config->get('mode');
     $packages = $command->getCSS();
     if ($mode == 'production') {
         $this->packageForProduction($packages);
     } else {
         $this->packageForDevelopment($packages);
     }
 }
开发者ID:erkie,项目名称:cowl,代码行数:10,代码来源:plugin.css.php


示例9: query

 /**
  * Queries the google analytics service.
  *
  * @param Command $command The command with the query params
  *
  * @return Response If an error occurred when querying the google analytics service.
  *
  * @throws GoogleAnalyticsException If Query is invalid
  *
  */
 public function query(Command $command)
 {
     $accessToken = $this->getClient()->getAccessToken();
     $uri = $command->build($accessToken);
     $content = $this->getClient()->getHttpAdapter()->getContent($uri);
     $json = json_decode($content, true);
     if (!is_array($json) || isset($json['error'])) {
         throw GoogleAnalyticsException::invalidQuery(isset($json['error']) ? $json['error']['message'] : 'Invalid json');
     }
     return new Response($json, $command);
 }
开发者ID:coradite,项目名称:yii-google-analytics,代码行数:21,代码来源:Service.php


示例10: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     switch (strtolower($command->getName())) {
         case "changepw":
             //Change password...
             break;
         case "unregister":
             //Unregister...
             break;
     }
 }
开发者ID:Jackboy320,项目名称:xAuth,代码行数:11,代码来源:CommandManager.php


示例11: execute

 /**
  * @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;
 }
开发者ID:app2641,项目名称:DesignPatternOnPHP,代码行数:15,代码来源:JobCommand.php


示例12: runCommand

 /**
  * @param string             $name
  * @param null|string|array  $comandArgument
  * @param null|Callable      $lineCallback
  * @return null|string
  */
 public function runCommand($name, $comandArgument = null, $lineCallback = null)
 {
     $output = null;
     $command = new Command($name, $comandArgument);
     $command->setSh($this);
     if (is_null($lineCallback)) {
         return $command;
     } else {
         $command->setLineCallback($lineCallback);
         return $command->doCallback();
     }
 }
开发者ID:gonzalo123,项目名称:sh,代码行数:18,代码来源:Sh.php


示例13: assignCommand

 /**
  * Zpracuje command a nastavi vlastnosti objektu.
  *
  * @return Bobr_AbstractModule
  */
 protected function assignCommand()
 {
     $command = $this->command->toArray();
     array_shift($command);
     if (isset($command[0])) {
         $this->setAction($command[0]);
         array_shift($command);
         if (isset($command[0])) {
             $this->setParams($command);
         }
     } else {
         $this->action = 'default';
     }
     return $this;
 }
开发者ID:laiello,项目名称:webuntucms,代码行数:20,代码来源:AbstractModule.php


示例14: handle

 public function handle(Command $command, ClientContext $context) : Generator
 {
     if ($command->argCount() === 0) {
         $group = $this->currentGroup;
     }
     $name = $command->arg(0);
     $group = (yield from $context->getAccessLayer()->getGroupByName($name));
     if (!$group) {
         yield from $context->writeResponse(new Response(411, 'No such newsgroup'));
         return;
     }
     $context->setCurrentGroup($group->name());
     $context->setCurrentArticle($group->lowWaterMark());
     yield from $context->writeResponse(new Response(211, $group->count() . ' ' . $group->lowWaterMark() . ' ' . $group->highWaterMark() . ' ' . $group->name() . ' Group successfully selected'));
 }
开发者ID:coderstephen,项目名称:libnntp,代码行数:15,代码来源:ListGroupHandler.php


示例15: validateParams

 /**
  * Overrides ITC\Weixin\Payment\Command\Command#validateParams.
  *
  * @param void
  *
  * @return array
  */
 protected function validateParams(array $params, array &$errors)
 {
     parent::validateParams($params, $errors);
     if ($params['trade_type'] === 'JSAPI' && empty($params['openid'])) {
         $errors[] = 'openid parameter is required if trade_type is JSAPI';
     }
 }
开发者ID:benjah1,项目名称:weixin-payment,代码行数:14,代码来源:CreateUnifiedOrder.php


示例16: play

 public function play()
 {
     $command = '';
     if ($this->game['status'] == Game::GAME_STATUS_INITIALIZED) {
         $command = $this->selectCharacter();
     } elseif ($this->player['phase'] == Player::PHASE_DRAW_HIGH_NOON) {
         $command = $this->drawOneTurnCard();
     } elseif ($this->player['phase'] == Player::PHASE_DYNAMITE) {
         $command = $this->drawDynamite();
     } elseif ($this->player['phase'] == Player::PHASE_JAIL) {
         $command = $this->drawJail();
     } elseif ($this->player['phase'] == Player::PHASE_RATTLESNAKE) {
         $command = $this->drawRattlesnake();
     } elseif ($this->player['phase'] == Player::PHASE_DRAW) {
         $command = $this->draw();
     } elseif ($this->player['phase'] == Player::PHASE_PLAY) {
         if ($this->player['possible_choices'] != '') {
             $command = $this->chooseCards();
         } else {
             $command = $this->playCards();
         }
     } elseif ($this->player['phase'] == Player::PHASE_UNDER_ATTACK) {
         $command = $this->reactToAttack();
     } elseif ($this->player['phase'] == Player::PHASE_HIGH_NOON) {
         $command = $this->takeLifeDown();
     } else {
         $this->whatToDo();
     }
     if ($command) {
         Log::logAiAction('ai player ' . $this->player['id'] . ': ' . $command);
         Command::setup($command, $this->game, $this->player);
     }
 }
开发者ID:Tomeno,项目名称:lulcobang,代码行数:33,代码来源:AbstractStrategy.php


示例17: fromArray

 /**
  * @return ScriptInfo
  */
 public static function fromArray($array)
 {
     $object = parent::fromArray($array);
     $object->paramDescs = ScriptSettings::fromArrayOfArray($object->paramDescs);
     $object->commandDescs = Command::fromArrayOfArray($object->commandDescs);
     return $object;
 }
开发者ID:maniaplanet,项目名称:dedicated-server-api,代码行数:10,代码来源:ScriptInfo.php


示例18: render

 /**
  * ページを表示する。
  *
  * @param	array(string => string)	$value	スキンに渡す値。bodyとtitleは必須。
  */
 function render($value)
 {
     $command = array();
     foreach (Command::getCommands() as $c) {
         $html = $c->getbody();
         if ($html != '') {
             $command[substr(get_class($c), 8)] = $html;
         }
     }
     $plugin = array();
     foreach (Plugin::getPlugins() as $c) {
         $html = $c->getbody();
         if ($html != '') {
             $plugin[substr(get_class($c), 7)] = $html;
         }
     }
     $this->smarty->assign('command', $command);
     $this->smarty->assign('plugin', $plugin);
     $this->smarty->assign('option', $this->option);
     $this->smarty->assign('headeroption', $this->headeroption);
     $this->smarty->assign('theme', $this->theme);
     $this->smarty->assign($value);
     header('Content-Type: text/html; charset=UTF-8');
     $this->smarty->assign('runningtime', sprintf('%.3f', mtime() - STARTTIME));
     $this->smarty->display(SKINFILE);
 }
开发者ID:riaf,项目名称:kinowiki,代码行数:31,代码来源:renderer.inc.php


示例19: getAll

 public function getAll()
 {
     if (!isset($this->Elements) || $this->countElements() < 0) {
         return Command::getEmptyInstance();
     }
     return $this->Elements;
 }
开发者ID:0xF3ERROR,项目名称:Home-Control,代码行数:7,代码来源:cls_CommandCollection.php


示例20: validateParams

 /**
  * Overrides ITC\Weixin\Payment\Command\Command#validateParams
  * @param void
  * @return array
  */
 protected function validateParams(array $params, array &$errors)
 {
     parent::validateParams($params, $errors);
     if (empty($params['transaction_id']) && empty($params['out_trade_no'])) {
         $errors[] = 'transaction_id and out_trade_no cannot *both* be empty';
     }
 }
开发者ID:joy2fun,项目名称:weixin-payment,代码行数:12,代码来源:OrderQuery.php



注:本文中的Command类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CommandContext类代码示例发布时间:2022-05-23
下一篇:
PHP Combo类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap