Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • AbstractCommand
  • ClosureCommand
  • DefaultRequestSerializer
  • DefaultResponseParser
  • OperationCommand
  • OperationResponseParser

Interfaces

  • CommandInterface
  • RequestSerializerInterface
  • ResponseClassInterface
  • ResponseParserInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
  1: <?php
  2: 
  3: namespace Guzzle\Service\Command;
  4: 
  5: use Guzzle\Service\Description\OperationInterface;
  6: 
  7: /**
  8:  * A command that creates requests based on {@see Guzzle\Service\Description\OperationInterface} objects, and if the
  9:  * matching operation uses a service description model in the responseClass attribute, then this command will marshal
 10:  * the response into an associative array based on the JSON schema of the model.
 11:  */
 12: class OperationCommand extends AbstractCommand
 13: {
 14:     /**
 15:      * @var RequestSerializerInterface
 16:      */
 17:     protected $requestSerializer;
 18: 
 19:     /**
 20:      * @var ResponseParserInterface Response parser
 21:      */
 22:     protected $responseParser;
 23: 
 24:     /**
 25:      * Set the response parser used with the command
 26:      *
 27:      * @param ResponseParserInterface $parser Response parser
 28:      *
 29:      * @return self
 30:      */
 31:     public function setResponseParser(ResponseParserInterface $parser)
 32:     {
 33:         $this->responseParser = $parser;
 34: 
 35:         return $this;
 36:     }
 37: 
 38:     /**
 39:      * Set the request serializer used with the command
 40:      *
 41:      * @param RequestSerializerInterface $serializer Request serializer
 42:      *
 43:      * @return self
 44:      */
 45:     public function setRequestSerializer(RequestSerializerInterface $serializer)
 46:     {
 47:         $this->requestSerializer = $serializer;
 48: 
 49:         return $this;
 50:     }
 51: 
 52:     /**
 53:      * Get the request serializer used with the command
 54:      *
 55:      * @return RequestSerializerInterface
 56:      */
 57:     public function getRequestSerializer()
 58:     {
 59:         if (!$this->requestSerializer) {
 60:             // Use the default request serializer if none was found
 61:             $this->requestSerializer = DefaultRequestSerializer::getInstance();
 62:         }
 63: 
 64:         return $this->requestSerializer;
 65:     }
 66: 
 67:     /**
 68:      * Get the response parser used for the operation
 69:      *
 70:      * @return ResponseParserInterface
 71:      */
 72:     public function getResponseParser()
 73:     {
 74:         if (!$this->responseParser) {
 75:             // Use the default response parser if none was found
 76:             $this->responseParser = OperationResponseParser::getInstance();
 77:         }
 78: 
 79:         return $this->responseParser;
 80:     }
 81: 
 82:     /**
 83:      * {@inheritdoc}
 84:      */
 85:     protected function build()
 86:     {
 87:         // Prepare and serialize the request
 88:         $this->request = $this->getRequestSerializer()->prepare($this);
 89:     }
 90: 
 91:     /**
 92:      * {@inheritdoc}
 93:      */
 94:     protected function process()
 95:     {
 96:         // Do not process the response if 'command.response_processing' is set to 'raw'
 97:         $this->result = $this->get(self::RESPONSE_PROCESSING) == self::TYPE_RAW
 98:             ? $this->request->getResponse()
 99:             : $this->getResponseParser()->parse($this);
100:     }
101: }
102: 
php-coveralls API documentation generated by ApiGen 2.8.0