/** * Handles the processing workflow of a command after it has been sent. * * @param CommandTransaction $trans Command execution context * @throws \Exception */ public static function process(CommandTransaction $trans) { // Throw if an exception occurred while sending the request if ($e = $trans->getException()) { $trans->setException(null); throw $e; } try { $trans->getCommand()->getEmitter()->emit('process', new ProcessEvent($trans)); } catch (\Exception $e) { self::emitError($trans, $e); } }
public function testCanMutateData() { $client = $this->getMockForAbstractClass('GuzzleHttp\\Command\\ServiceClientInterface'); $command = new Command('foo', []); $trans = new CommandTransaction($client, $command, ['foo' => 'bar']); $request = new Request('GET', 'http://foo.com'); $trans->setRequest($request); $this->assertSame($request, $trans->getRequest()); $response = new Response(200); $trans->setResponse($response); $this->assertSame($response, $trans->getResponse()); $trans->setResult('foo'); $this->assertSame('foo', $trans->getResult()); $e = new \Exception('foo'); $trans->setException($e); $this->assertSame($e, $trans->getException()); }