当前位置: 首页>>代码示例>>PHP>>正文


PHP Command类代码示例

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


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


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