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