@@ 571-581 (lines=11) @@ | ||
568 | $this->methodBody->add('$request = $beforeSendEvent->getRequest();'); |
|
569 | $this->methodBody->add('try {'); |
|
570 | ||
571 | if ($this->callback !== null && $this->callbackOptional) { |
|
572 | $this->methodBody->add('if (%s !== null) {', $this->callback); |
|
573 | $this->methodBody->add('$response = $this->client->sendAsync($request, %s);', $this->callback); |
|
574 | $this->methodBody->add('} else {'); |
|
575 | $this->methodBody->add('$response = $this->client->send($request);'); |
|
576 | $this->methodBody->add('}'); |
|
577 | } elseif ($this->callback !== null && !$this->callbackOptional) { |
|
578 | $this->methodBody->add('$response = $this->client->sendAsync($request, %s);', $this->callback); |
|
579 | } else { |
|
580 | $this->methodBody->add('$response = $this->client->send($request);'); |
|
581 | } |
|
582 | ||
583 | $this->methodBody->add('} catch (\Exception $exception) {'); |
|
584 | $this->methodBody->add('$apiExceptionEvent = new \Tebru\Retrofit\Event\ApiExceptionEvent($exception, $request);'); |
|
@@ 599-611 (lines=13) @@ | ||
596 | */ |
|
597 | private function createReturns() |
|
598 | { |
|
599 | if ($this->callback !== null && $this->callbackOptional) { |
|
600 | $this->methodBody->add('if (%s !== null) {', $this->callback); |
|
601 | $this->methodBody->add('$returnEvent = new \Tebru\Retrofit\Event\ReturnEvent(null);'); |
|
602 | $this->methodBody->add('$this->eventDispatcher->dispatch("retrofit.return", $returnEvent);'); |
|
603 | $this->methodBody->add('return $returnEvent->getReturn();'); |
|
604 | $this->methodBody->add('}'); |
|
605 | } elseif ($this->callback !== null && !$this->callbackOptional) { |
|
606 | $this->methodBody->add('$returnEvent = new \Tebru\Retrofit\Event\ReturnEvent(null);'); |
|
607 | $this->methodBody->add('$this->eventDispatcher->dispatch("retrofit.return", $returnEvent);'); |
|
608 | $this->methodBody->add('return $returnEvent->getReturn();'); |
|
609 | ||
610 | return; |
|
611 | } |
|
612 | ||
613 | $matches = []; |
|
614 | $returnType = $this->returnType; |