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


PHP CommandInterface::getRequest方法代码示例

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


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

示例1: addMd5

 private function addMd5(CommandInterface $command)
 {
     $request = $command->getRequest();
     if ($body = $request->getBody()) {
         if (false !== ($md5 = $body->getContentMd5(true, true))) {
             $request->setHeader('Content-MD5', $md5);
         }
     }
 }
开发者ID:viggi2004,项目名称:datacollector-backend,代码行数:9,代码来源:S3Md5Listener.php

示例2: addMd5

 private function addMd5(CommandInterface $command)
 {
     $request = $command->getRequest();
     if ($body = $request->getBody()) {
         if (false === ($md5 = $body->getContentMd5(true, true))) {
             throw new RuntimeException('Unable to add a MD5 checksum');
         }
         $request->setHeader('Content-MD5', $md5);
     }
 }
开发者ID:iLoiLohas,项目名称:pinchshopper,代码行数:10,代码来源:S3Md5Listener.php

示例3: parse

 public function parse(CommandInterface $command)
 {
     $response = $command->getRequest()->getResponse();
     if ($contentType = $command['command.expects']) {
         $response->setHeader('Content-Type', $contentType);
     } else {
         $contentType = (string) $response->getHeader('Content-Type');
     }
     return $this->handleParsing($command, $response, $contentType);
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:10,代码来源:DefaultResponseParser.php

示例4: fromCommand

 /**
  * {@inheritDoc}
  */
 public static function fromCommand(CommandInterface $command, Response $response)
 {
     $errors = json_decode($response->getBody(true), true);
     $type = array_get($errors, 'error.type', null);
     $code = array_get($errors, 'error.code', null);
     $message = array_get($errors, 'error.message', null);
     $class = '\\Apache\\Usergrid\\Api\\Exception\\' . studly_case($type) . 'Exception';
     if (class_exists($class)) {
         $exception = new $class($message, $response->getStatusCode());
     } else {
         $exception = new static($message, $response->getStatusCode());
     }
     $exception->setErrorType($type);
     $exception->setResponse($response);
     $exception->setRequest($command->getRequest());
     return $exception;
 }
开发者ID:funkyidol,项目名称:usergrid,代码行数:20,代码来源:UsergridException.php

示例5: parse

 /**
  * {@inheritdoc}
  *
  * @param CommandInterface $command
  * @return array|MultiResultResponse|SingleResultResponse|Response|mixed
  */
 public function parse(CommandInterface $command)
 {
     $response = $command->getRequest()->getResponse();
     if ($response === null) {
         return null;
     }
     $responseArray = $this->parseResponseIntoArray($response);
     // If there is no Body, just return the Response
     if (!$response->getBody()) {
         return $response;
     }
     // Handle multi-result responses
     if (array_key_exists('results', $responseArray)) {
         return $this->createMultiResultResponse($response);
     }
     return $this->createSingleResultResponse($response);
 }
开发者ID:opdavies,项目名称:nwdrupalwebsite,代码行数:23,代码来源:MeetupResponseParser.php

示例6: fromCommand

 /**
  * {@inheritDoc}
  */
 public static function fromCommand(CommandInterface $command, Response $response)
 {
     $errors = json_decode($response->getBody(true), true);
     $type = $errors['error']['type'];
     $message = isset($errors['error']['message']) ? $errors['error']['message'] : 'Unknown error';
     $code = isset($errors['error']['code']) ? $errors['error']['code'] : null;
     // We can trigger very specific exception based on the type and code
     if ($type === 'card_error') {
         $exception = new CardErrorException($message, $response->getStatusCode());
     } elseif ($type === 'invalid_request_error' && $code === 'rate_limit') {
         $exception = new ApiRateLimitException($message, $response->getStatusCode());
     } else {
         $exception = new static($message, $response->getStatusCode());
     }
     $exception->setRequest($command->getRequest());
     $exception->setResponse($response);
     return $exception;
 }
开发者ID:netglue,项目名称:zfr-stripe,代码行数:21,代码来源:AbstractResponseException.php

示例7: getExceptionForFailedCommand

 /**
  * Get the Exception that caused the given $command to fail
  *
  * @param CommandInterface $command Failed command
  *
  * @return \Exception|null
  */
 public function getExceptionForFailedCommand(CommandInterface $command)
 {
     return $this->getExceptionForFailedRequest($command->getRequest());
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:11,代码来源:CommandTransferException.php

示例8: parse

 /**
  * {@inheritdoc}
  */
 public function parse(CommandInterface $command)
 {
     $response = $command->getRequest()->getResponse();
     $contentType = (string) $response->getHeader('Content-Type');
     return $this->handleParsing($command, $response, $contentType);
 }
开发者ID:aciliainternet,项目名称:guzzle-bundle,代码行数:9,代码来源:JMSSerializerResponseParser.php

示例9: 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) {
         $command->setClient($this)->prepare();
         $this->dispatch('command.before_send', array('command' => $command));
         $command->getRequest()->send();
         $this->dispatch('command.after_send', array('command' => $command));
         return $command->getResult();
     } else {
         if ($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();
         } else {
             if (is_array($command)) {
                 return $this->execute(new CommandSet($command));
             }
         }
     }
     throw new InvalidArgumentException('Invalid command sent to ' . __METHOD__);
 }
开发者ID:MicroSDHC,项目名称:justinribeiro.com-examples,代码行数:37,代码来源:Client.php

示例10: parse

 /**
  * {@inheritdoc}
  */
 public function parse(CommandInterface $command)
 {
     $content = $command->getRequest()->getResponse()->getBody(true);
     return json_decode(preg_replace('/^availableFeeds=/', '', $content), true);
 }
开发者ID:adrienbrault,项目名称:itunes-client,代码行数:8,代码来源:ListFeedsCommand.php


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