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


PHP CommandInterface::setClient方法代码示例

本文整理汇总了PHP中Guzzle\Service\Command\CommandInterface::setClient方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandInterface::setClient方法的具体用法?PHP CommandInterface::setClient怎么用?PHP CommandInterface::setClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Guzzle\Service\Command\CommandInterface的用法示例。


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

示例1: prepareCommand

 protected function prepareCommand(CommandInterface $command)
 {
     $request = $command->setClient($this)->prepare();
     $request->setState(RequestInterface::STATE_NEW);
     $this->dispatch('command.before_send', array('command' => $command));
     return $request;
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:7,代码来源:Client.php

示例2: prepareCommand

 /**
  * Prepare a command for sending and get the RequestInterface object created by the command
  *
  * @param CommandInterface $command Command to prepare
  *
  * @return RequestInterface
  */
 protected function prepareCommand(CommandInterface $command)
 {
     // Set the client and prepare the command
     $request = $command->setClient($this)->prepare();
     // Set the state to new if the command was previously executed
     $request->setState(RequestInterface::STATE_NEW);
     $this->dispatch('command.before_send', array('command' => $command));
     return $request;
 }
开发者ID:carlyns,项目名称:RESUSblog,代码行数:16,代码来源:Client.php

示例3: execute

 /**
  * Execute a command and return the response
  *
  * @param CommandInterface|CommandSet|array $command Command or set to execute
  *
  * @return mixed Returns the result of the executed command's
  *       {@see CommandInterface::getResult} method if a CommandInterface is
  *       passed, or the CommandSet itself if a CommandSet is passed
  * @throws InvalidArgumentException if an invalid command is passed
  * @throws CommandSetException if a set contains commands associated with other clients
  */
 public function execute($command)
 {
     if ($command instanceof CommandInterface) {
         $request = $command->setClient($this)->prepare();
         $this->dispatch('command.before_send', array('command' => $command));
         // Set the state to new if the command was previously executed
         if ($request->getState() !== RequestInterface::STATE_NEW) {
             $request->setState(RequestInterface::STATE_NEW);
         }
         $request->send();
         $this->dispatch('command.after_send', array('command' => $command));
         return $command->getResult();
     } elseif ($command instanceof CommandSet) {
         foreach ($command as $c) {
             if ($c->getClient() && $c->getClient() !== $this) {
                 throw new CommandSetException('Attempting to run a mixed-Client CommandSet from a ' . 'Client context.  Run the set using CommandSet::execute() ');
             }
             $c->setClient($this);
         }
         return $command->execute();
     } elseif (is_array($command)) {
         return $this->execute(new CommandSet($command));
     }
     throw new InvalidArgumentException('Invalid command sent to ' . __METHOD__);
 }
开发者ID:norv,项目名称:guzzle,代码行数:36,代码来源:Client.php


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