vendor/symfony/config/ResourceCheckerConfigCacheFactory.php line 39

  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Config;
  11. /**
  12.  * A ConfigCacheFactory implementation that validates the
  13.  * cache with an arbitrary set of ResourceCheckers.
  14.  *
  15.  * @author Matthias Pigulla <mp@webfactory.de>
  16.  */
  17. class ResourceCheckerConfigCacheFactory implements ConfigCacheFactoryInterface
  18. {
  19.     private iterable $resourceCheckers = [];
  20.     /**
  21.      * @param iterable<int, ResourceCheckerInterface> $resourceCheckers
  22.      */
  23.     public function __construct(iterable $resourceCheckers = [])
  24.     {
  25.         $this->resourceCheckers $resourceCheckers;
  26.     }
  27.     public function cache(string $file, callable $callable): ConfigCacheInterface
  28.     {
  29.         $cache = new ResourceCheckerConfigCache($file$this->resourceCheckers);
  30.         if (!$cache->isFresh()) {
  31.             $callable($cache);
  32.         }
  33.         return $cache;
  34.     }
  35. }