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;
15 * Basic implementation of ConfigCacheFactoryInterface that
16 * creates an instance of the default ConfigCache.
18 * This factory and/or cache <em>do not</em> support cache validation
19 * by means of ResourceChecker instances (that is, service-based).
21 * @author Matthias Pigulla <mp@webfactory.de>
23 class ConfigCacheFactory implements ConfigCacheFactoryInterface
26 * @var bool Debug flag passed to the ConfigCache
31 * @param bool $debug The debug flag to pass to ConfigCache
33 public function __construct($debug)
35 $this->debug = $debug;
41 public function cache($file, $callback)
43 if (!is_callable($callback)) {
44 throw new \InvalidArgumentException(sprintf('Invalid type for callback argument. Expected callable, but got "%s".', gettype($callback)));
47 $cache = new ConfigCache($file, $this->debug);
48 if (!$cache->isFresh()) {
49 call_user_func($callback, $cache);