vendor/symfony/config/ConfigCache.php line 58

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Config;
  11. use Symfony\Component\Config\Resource\SelfCheckingResourceChecker;
  12. /**
  13.  * ConfigCache caches arbitrary content in files on disk.
  14.  *
  15.  * When in debug mode, those metadata resources that implement
  16.  * \Symfony\Component\Config\Resource\SelfCheckingResourceInterface will
  17.  * be used to check cache freshness.
  18.  *
  19.  * @author Fabien Potencier <fabien@symfony.com>
  20.  * @author Matthias Pigulla <mp@webfactory.de>
  21.  */
  22. class ConfigCache extends ResourceCheckerConfigCache {
  23.     private $debug;
  24.     /**
  25.      * @param string $file  The absolute cache path
  26.      * @param bool   $debug Whether debugging is enabled or not
  27.      */
  28.     public function __construct(string $filebool $debug) {
  29.         $this->debug $debug;
  30.         $checkers = [];
  31.         if (true === $this->debug) {
  32.             $checkers = [new SelfCheckingResourceChecker()];
  33.         }
  34.         parent::__construct($file$checkers);
  35.     }
  36.     /**
  37.      * Checks if the cache is still fresh.
  38.      *
  39.      * This implementation always returns true when debug is off and the
  40.      * cache file exists.
  41.      *
  42.      * @return bool true if the cache is fresh, false otherwise
  43.      */
  44.     public function isFresh() {
  45.         if (!$this->debug && is_file($this->getPath())) {
  46.             return true;
  47.         }
  48.         return parent::isFresh();
  49.     }
  50. }