getRequest() public method

Gets the Request instance associated with the master request.
public getRequest ( ) : Request
return Symfony\Component\HttpFoundation\Request A Request instance
Esempio n. 1
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;
         }
     }
 }