Beispiel #1
0
 /**
  * Forwards the Request to the backend and returns the Response.
  *
  * @param Symfony\Components\HttpFoundation\Response  $request  A Request instance
  * @param Boolean                                $raw      Whether to catch exceptions or not
  * @param Symfony\Components\HttpFoundation\Response $response A Response instance (the stale entry if present, null otherwise)
  *
  * @return Symfony\Components\HttpFoundation\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);
 }
Beispiel #2
0
 /**
  * Handles an ESI from the cache.
  *
  * @param Symfony\Components\HttpKernel\Cache\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 {
         return $cache->handle($subRequest, HttpKernelInterface::EMBEDDED_REQUEST, true);
     } catch (\Exception $e) {
         if ($alt) {
             return $this->handle($cache, $alt, '', $ignoreErrors);
         }
         if (!$ignoreErrors) {
             throw $e;
         }
     }
 }