vendor/symfony/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     1 <?php
       
     2 
       
     3 namespace Symfony\Bundle\FrameworkBundle\HttpCache;
       
     4 
       
     5 use Symfony\Component\HttpKernel\HttpKernelInterface;
       
     6 use Symfony\Component\HttpKernel\HttpCache\HttpCache as BaseHttpCache;
       
     7 use Symfony\Component\HttpKernel\HttpCache\Esi;
       
     8 use Symfony\Component\HttpKernel\HttpCache\EsiResponseCacheStrategy;
       
     9 use Symfony\Component\HttpKernel\HttpCache\Store;
       
    10 use Symfony\Component\HttpFoundation\Request;
       
    11 use Symfony\Component\HttpFoundation\Response;
       
    12 
       
    13 /*
       
    14  * This file is part of the Symfony package.
       
    15  *
       
    16  * (c) Fabien Potencier <fabien@symfony.com>
       
    17  *
       
    18  * For the full copyright and license information, please view the LICENSE
       
    19  * file that was distributed with this source code.
       
    20  */
       
    21 
       
    22 /**
       
    23  *
       
    24  * @author Fabien Potencier <fabien@symfony.com>
       
    25  */
       
    26 abstract class HttpCache extends BaseHttpCache
       
    27 {
       
    28     /**
       
    29      * Constructor.
       
    30      *
       
    31      * @param HttpKernelInterface $kernel An HttpKernelInterface instance
       
    32      */
       
    33     public function __construct(HttpKernelInterface $kernel)
       
    34     {
       
    35         $store = new Store($kernel->getCacheDir().'/http_cache');
       
    36         $esi = new Esi();
       
    37 
       
    38         parent::__construct($kernel, $store, $esi, array_merge(array('debug' => $kernel->isDebug()), $this->getOptions()));
       
    39     }
       
    40 
       
    41     /**
       
    42      * Forwards the Request to the backend and returns the Response.
       
    43      *
       
    44      * @param Request  $request A Request instance
       
    45      * @param Boolean  $raw     Whether to catch exceptions or not
       
    46      * @param Response $entry   A Response instance (the stale entry if present, null otherwise)
       
    47      *
       
    48      * @return Response A Response instance
       
    49      */
       
    50     protected function forward(Request $request, $raw = false, Response $entry = null)
       
    51     {
       
    52         $this->getKernel()->boot();
       
    53         $this->getKernel()->getContainer()->set('cache', $this);
       
    54         $this->getKernel()->getContainer()->set('esi', $this->getEsi());
       
    55 
       
    56         return parent::forward($request, $raw, $entry);
       
    57     }
       
    58 
       
    59     /**
       
    60      * Returns an array of options to customize the Cache configuration.
       
    61      *
       
    62      * @return array An array of options
       
    63      */
       
    64     protected function getOptions()
       
    65     {
       
    66         return array();
       
    67     }
       
    68 }