Open Journal Systems  3.3.0
OperationCommand.php
1 <?php
2 
3 namespace Guzzle\Service\Command;
4 
11 {
13  protected $requestSerializer;
14 
16  protected $responseParser;
17 
25  public function setResponseParser(ResponseParserInterface $parser)
26  {
27  $this->responseParser = $parser;
28 
29  return $this;
30  }
31 
39  public function setRequestSerializer(RequestSerializerInterface $serializer)
40  {
41  $this->requestSerializer = $serializer;
42 
43  return $this;
44  }
45 
51  public function getRequestSerializer()
52  {
53  if (!$this->requestSerializer) {
54  // Use the default request serializer if none was found
55  $this->requestSerializer = DefaultRequestSerializer::getInstance();
56  }
57 
59  }
60 
66  public function getResponseParser()
67  {
68  if (!$this->responseParser) {
69  // Use the default response parser if none was found
70  $this->responseParser = OperationResponseParser::getInstance();
71  }
72 
73  return $this->responseParser;
74  }
75 
76  protected function build()
77  {
78  // Prepare and serialize the request
79  $this->request = $this->getRequestSerializer()->prepare($this);
80  }
81 
82  protected function process()
83  {
84  // Do not process the response if 'command.response_processing' is set to 'raw'
85  $this->result = $this[self::RESPONSE_PROCESSING] == self::TYPE_RAW
86  ? $this->request->getResponse()
87  : $this->getResponseParser()->parse($this);
88  }
89 }
Guzzle\Service\Command
Definition: AbstractCommand.php:3
Guzzle\Service\Command\OperationCommand\getRequestSerializer
getRequestSerializer()
Definition: OperationCommand.php:57
Guzzle\Service\Command\ResponseParserInterface
Definition: ResponseParserInterface.php:8
Guzzle\Service\Command\OperationCommand\$responseParser
$responseParser
Definition: OperationCommand.php:22
Guzzle\Service\Command\OperationCommand\process
process()
Definition: OperationCommand.php:88
Guzzle\Service\Command\OperationCommand
Definition: OperationCommand.php:10
Guzzle\Service\Command\OperationCommand\getResponseParser
getResponseParser()
Definition: OperationCommand.php:72
Guzzle\Service\Command\RequestSerializerInterface
Definition: RequestSerializerInterface.php:11
Guzzle\Service\Command\OperationCommand\setResponseParser
setResponseParser(ResponseParserInterface $parser)
Definition: OperationCommand.php:31
Guzzle\Service\Command\DefaultRequestSerializer\getInstance
static getInstance()
Definition: DefaultRequestSerializer.php:29
Guzzle\Service\Command\OperationCommand\$requestSerializer
$requestSerializer
Definition: OperationCommand.php:16
Guzzle\Service\Command\OperationResponseParser\getInstance
static getInstance()
Definition: OperationResponseParser.php:38
Guzzle\Service\Command\AbstractCommand\RESPONSE_PROCESSING
const RESPONSE_PROCESSING
Definition: AbstractCommand.php:37
Guzzle\Service\Command\OperationCommand\build
build()
Definition: OperationCommand.php:82
Guzzle\Service\Command\OperationCommand\setRequestSerializer
setRequestSerializer(RequestSerializerInterface $serializer)
Definition: OperationCommand.php:45
Guzzle\Service\Command\AbstractCommand
Definition: AbstractCommand.php:21