/** * {@inheritdoc} */ protected function doSendInternalRequests(array $internalRequests) { foreach ($internalRequests as &$internalRequest) { $internalRequest = $this->authentication->authenticate($internalRequest); } return parent::doSendInternalRequests($internalRequests); }
/** * {@inheritdoc} */ protected function doSendInternalRequests(array $internalRequests) { if (!empty($internalRequests)) { $this->eventDispatcher->dispatch(Events::MULTI_REQUEST_CREATED, $multiRequestCreatedEvent = new MultiRequestCreatedEvent($this, $internalRequests)); $internalRequests = $multiRequestCreatedEvent->getRequests(); } $exceptions = array(); try { $responses = parent::doSendInternalRequests($internalRequests); } catch (MultiHttpAdapterException $e) { $responses = $e->getResponses(); $exceptions = $e->getExceptions(); } if (!empty($responses)) { $this->eventDispatcher->dispatch(Events::MULTI_REQUEST_SENT, $requestSentEvent = new MultiRequestSentEvent($this, $responses)); $exceptions = array_merge($exceptions, $requestSentEvent->getExceptions()); $responses = $requestSentEvent->getResponses(); } if (!empty($exceptions)) { $this->eventDispatcher->dispatch(Events::MULTI_REQUEST_ERRORED, $exceptionEvent = new MultiRequestErroredEvent($this, $exceptions)); $responses = array_merge($responses, $exceptionEvent->getResponses()); $exceptions = $exceptionEvent->getExceptions(); if (!empty($exceptions)) { throw new MultiHttpAdapterException($exceptions, $responses); } } return $responses; }
/** * {@inheritdoc} */ protected function decorate($method, array $params = array()) { $this->stopwatch->start($name = 'ivory.http_adapter'); try { $result = parent::decorate($method, $params); } catch (\Exception $e) { $this->stopwatch->stop($name); throw $e; } $this->stopwatch->stop($name); return $result; }
/** * {@inheritdoc} */ protected function doSendInternalRequests(array $internalRequests) { $this->stopwatch->start($name = 'ivory.http_adapter'); try { $result = parent::doSendInternalRequests($internalRequests); } catch (\Exception $e) { $this->stopwatch->stop($name); throw $e; } $this->stopwatch->stop($name); return $result; }
/** * {@inheritdoc} */ protected function sendInternalRequest(InternalRequestInterface $internalRequest) { try { $this->eventDispatcher->dispatch(Events::PRE_SEND, $preSendEvent = new PreSendEvent($this, $internalRequest)); $response = parent::sendInternalRequest($preSendEvent->getRequest()); $this->eventDispatcher->dispatch(Events::POST_SEND, $postSendEvent = new PostSendEvent($this, $preSendEvent->getRequest(), $response)); if ($postSendEvent->hasException()) { throw $postSendEvent->getException(); } $response = $postSendEvent->getResponse(); } catch (HttpAdapterException $e) { $e->setRequest($internalRequest); $e->setResponse(isset($response) ? $response : null); $this->eventDispatcher->dispatch(Events::EXCEPTION, $exceptionEvent = new ExceptionEvent($this, $e)); if ($exceptionEvent->hasResponse()) { return $exceptionEvent->getResponse(); } throw $exceptionEvent->getException(); } return $response; }