當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。