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 * A ConfigCacheFactory implementation that validates the
16 * cache with an arbitrary set of ResourceCheckers.
18 * @author Matthias Pigulla <mp@webfactory.de>
20 class ResourceCheckerConfigCacheFactory implements ConfigCacheFactoryInterface
22 private $resourceCheckers = array();
25 * @param iterable|ResourceCheckerInterface[] $resourceCheckers
27 public function __construct($resourceCheckers = array())
29 $this->resourceCheckers = $resourceCheckers;
35 public function cache($file, $callback)
37 if (!\is_callable($callback)) {
38 throw new \InvalidArgumentException(sprintf('Invalid type for callback argument. Expected callable, but got "%s".', \gettype($callback)));
41 $cache = new ResourceCheckerConfigCache($file, $this->resourceCheckers);
42 if (!$cache->isFresh()) {
43 \call_user_func($callback, $cache);