4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Config;
14 use Symfony\Component\Config\Resource\SelfCheckingResourceChecker;
17 * ConfigCache caches arbitrary content in files on disk.
19 * When in debug mode, those metadata resources that implement
20 * \Symfony\Component\Config\Resource\SelfCheckingResourceInterface will
21 * be used to check cache freshness.
23 * @author Fabien Potencier <fabien@symfony.com>
24 * @author Matthias Pigulla <mp@webfactory.de>
26 class ConfigCache extends ResourceCheckerConfigCache
31 * @param string $file The absolute cache path
32 * @param bool $debug Whether debugging is enabled or not
34 public function __construct($file, $debug)
36 $this->debug = (bool) $debug;
39 if (true === $this->debug) {
40 $checkers = array(new SelfCheckingResourceChecker());
43 parent::__construct($file, $checkers);
47 * Checks if the cache is still fresh.
49 * This implementation always returns true when debug is off and the
52 * @return bool true if the cache is fresh, false otherwise
54 public function isFresh()
56 if (!$this->debug && is_file($this->getPath())) {
60 return parent::isFresh();