@@ 39-51 (lines=13) @@ | ||
36 | $context->body()->add('$request = $beforeSendEvent->getRequest();'); |
|
37 | $context->body()->add('try {'); |
|
38 | ||
39 | if (null !== $callback) { |
|
40 | if ($context->annotations()->isCallbackOptional()) { |
|
41 | $context->body()->add('if (%s !== null) {', $callback); |
|
42 | $context->body()->add('$response = $this->client->sendAsync($request, %s);', $callback); |
|
43 | $context->body()->add('} else {'); |
|
44 | $context->body()->add('$response = $this->client->send($request);'); |
|
45 | $context->body()->add('}'); |
|
46 | } else { |
|
47 | $context->body()->add('$response = $this->client->sendAsync($request, %s);', $callback); |
|
48 | } |
|
49 | } else { |
|
50 | $context->body()->add('$response = $this->client->send($request);'); |
|
51 | } |
|
52 | ||
53 | $context->body()->add('} catch (\Exception $exception) {'); |
|
54 | $context->body()->add('$apiExceptionEvent = new \Tebru\Retrofit\Event\ApiExceptionEvent($exception, $request);'); |
@@ 33-47 (lines=15) @@ | ||
30 | { |
|
31 | $callback = $context->annotations()->getCallback(); |
|
32 | ||
33 | if ($callback !== null) { |
|
34 | if ($context->annotations()->isCallbackOptional()) { |
|
35 | $context->body()->add('if (%s !== null) {', $callback); |
|
36 | $context->body()->add('$returnEvent = new \Tebru\Retrofit\Event\ReturnEvent(null);'); |
|
37 | $context->body()->add('$this->eventDispatcher->dispatch("retrofit.return", $returnEvent);'); |
|
38 | $context->body()->add('return $returnEvent->getReturn();'); |
|
39 | $context->body()->add('}'); |
|
40 | } else { |
|
41 | $context->body()->add('$returnEvent = new \Tebru\Retrofit\Event\ReturnEvent(null);'); |
|
42 | $context->body()->add('$this->eventDispatcher->dispatch("retrofit.return", $returnEvent);'); |
|
43 | $context->body()->add('return $returnEvent->getReturn();'); |
|
44 | ||
45 | return; |
|
46 | } |
|
47 | } |
|
48 | ||
49 | $returnType = 'array'; |
|
50 | if (null !== $context->annotations()->getReturnType()) { |