Author: Fabien Potencier (fabien.potencier@symfony-project.com)
Inheritance: implements Symfony\Component\HttpKernel\HttpKernelInterface
Esempio n. 1
0
 /**
  * Forwards the Request to the backend and returns the Response.
  *
  * @param Requset  $request  A Request instance
  * @param Boolean  $raw      Whether to catch exceptions or not
  * @param Response $response A Response instance (the stale entry if present, null otherwise)
  *
  * @return Response A Response instance
  */
 protected function forward(Request $request, $raw = false, Response $entry = null)
 {
     if (!$this->kernel->isBooted()) {
         $this->kernel->boot();
     }
     $this->kernel->getContainer()->set('cache', $this);
     $this->kernel->getContainer()->set('esi', $this->esi);
     return parent::forward($request, $raw, $entry);
 }
Esempio n. 2
0
File: Esi.php Progetto: rosstuck/Pok
 /**
  * Handles an ESI from the cache.
  *
  * @param Cache   $cache        A Cache instance
  * @param string  $uri          The main URI
  * @param string  $alt          An alternative URI
  * @param Boolean $ignoreErrors Whether to ignore errors or not
  */
 public function handle(Cache $cache, $uri, $alt, $ignoreErrors)
 {
     $subRequest = Request::create($uri, 'get', array(), $cache->getRequest()->cookies->all(), array(), $cache->getRequest()->server->all());
     try {
         $response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true);
         if (200 != $response->getStatusCode()) {
             throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $subRequest->getUri(), $response->getStatusCode()));
         }
         return $response->getContent();
     } catch (\Exception $e) {
         if ($alt) {
             return $this->handle($cache, $alt, '', $ignoreErrors);
         }
         if (!$ignoreErrors) {
             throw $e;
         }
     }
 }