function AbstractSurrogate::handle
Overrides SurrogateInterface::handle
File
-
vendor/
symfony/ http-kernel/ HttpCache/ AbstractSurrogate.php, line 71
Class
- AbstractSurrogate
- Abstract class implementing Surrogate capabilities to Request and Response instances.
Namespace
Symfony\Component\HttpKernel\HttpCacheCode
public function handle(HttpCache $cache, string $uri, string $alt, bool $ignoreErrors) : string {
$subRequest = Request::create($uri, Request::METHOD_GET, [], $cache->getRequest()->cookies
->all(), [], $cache->getRequest()->server
->all());
try {
$response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true);
if (!$response->isSuccessful() && Response::HTTP_NOT_MODIFIED !== $response->getStatusCode()) {
throw new \RuntimeException(\sprintf('Error when rendering "%s" (Status code is %d).', $subRequest->getUri(), $response->getStatusCode()));
}
return $response->getContent();
} catch (\Exception $e) {
if ($alt) {
return $this->handle($cache, $alt, '', $ignoreErrors);
}
if (!$ignoreErrors) {
throw $e;
}
}
return '';
}