[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/ -> CacheWarmerAggregate.php (source)

   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\HttpKernel\CacheWarmer;
  13  
  14  /**
  15   * Aggregates several cache warmers into a single one.
  16   *
  17   * @author Fabien Potencier <fabien@symfony.com>
  18   */
  19  class CacheWarmerAggregate implements CacheWarmerInterface
  20  {
  21      protected $warmers;
  22      protected $optionalsEnabled;
  23  
  24      public function __construct(array $warmers = array())
  25      {
  26          $this->setWarmers($warmers);
  27          $this->optionalsEnabled = false;
  28      }
  29  
  30      public function enableOptionalWarmers()
  31      {
  32          $this->optionalsEnabled = true;
  33      }
  34  
  35      /**
  36       * Warms up the cache.
  37       *
  38       * @param string $cacheDir The cache directory
  39       */
  40      public function warmUp($cacheDir)
  41      {
  42          foreach ($this->warmers as $warmer) {
  43              if (!$this->optionalsEnabled && $warmer->isOptional()) {
  44                  continue;
  45              }
  46  
  47              $warmer->warmUp($cacheDir);
  48          }
  49      }
  50  
  51      /**
  52       * Checks whether this warmer is optional or not.
  53       *
  54       * @return bool always false
  55       */
  56      public function isOptional()
  57      {
  58          return false;
  59      }
  60  
  61      public function setWarmers(array $warmers)
  62      {
  63          $this->warmers = array();
  64          foreach ($warmers as $warmer) {
  65              $this->add($warmer);
  66          }
  67      }
  68  
  69      public function add(CacheWarmerInterface $warmer)
  70      {
  71          $this->warmers[] = $warmer;
  72      }
  73  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1