Yaffs site version 1.1
[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\BCResourceInterfaceChecker;
15 use Symfony\Component\Config\Resource\SelfCheckingResourceChecker;
16
17 /**
18  * ConfigCache caches arbitrary content in files on disk.
19  *
20  * When in debug mode, those metadata resources that implement
21  * \Symfony\Component\Config\Resource\SelfCheckingResourceInterface will
22  * be used to check cache freshness.
23  *
24  * During a transition period, also instances of
25  * \Symfony\Component\Config\Resource\ResourceInterface will be checked
26  * by means of the isFresh() method. This behaviour is deprecated since 2.8
27  * and will be removed in 3.0.
28  *
29  * @author Fabien Potencier <fabien@symfony.com>
30  * @author Matthias Pigulla <mp@webfactory.de>
31  */
32 class ConfigCache extends ResourceCheckerConfigCache
33 {
34     private $debug;
35
36     /**
37      * @param string $file  The absolute cache path
38      * @param bool   $debug Whether debugging is enabled or not
39      */
40     public function __construct($file, $debug)
41     {
42         parent::__construct($file, array(
43             new SelfCheckingResourceChecker(),
44             new BCResourceInterfaceChecker(),
45         ));
46         $this->debug = (bool) $debug;
47     }
48
49     /**
50      * Gets the cache file path.
51      *
52      * @return string The cache file path
53      *
54      * @deprecated since 2.7, to be removed in 3.0. Use getPath() instead.
55      */
56     public function __toString()
57     {
58         @trigger_error('ConfigCache::__toString() is deprecated since version 2.7 and will be removed in 3.0. Use the getPath() method instead.', E_USER_DEPRECATED);
59
60         return $this->getPath();
61     }
62
63     /**
64      * Checks if the cache is still fresh.
65      *
66      * This implementation always returns true when debug is off and the
67      * cache file exists.
68      *
69      * @return bool true if the cache is fresh, false otherwise
70      */
71     public function isFresh()
72     {
73         if (!$this->debug && is_file($this->getPath())) {
74             return true;
75         }
76
77         return parent::isFresh();
78     }
79 }