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\HttpKernel\CacheWarmer;
15 * Aggregates several cache warmers into a single one.
17 * @author Fabien Potencier <fabien@symfony.com>
19 * @final since version 3.4
21 class CacheWarmerAggregate implements CacheWarmerInterface
23 protected $warmers = array();
24 protected $optionalsEnabled = false;
25 private $triggerDeprecation = false;
27 public function __construct($warmers = array())
29 foreach ($warmers as $warmer) {
32 $this->triggerDeprecation = true;
35 public function enableOptionalWarmers()
37 $this->optionalsEnabled = true;
43 * @param string $cacheDir The cache directory
45 public function warmUp($cacheDir)
47 foreach ($this->warmers as $warmer) {
48 if (!$this->optionalsEnabled && $warmer->isOptional()) {
52 $warmer->warmUp($cacheDir);
57 * Checks whether this warmer is optional or not.
59 * @return bool always false
61 public function isOptional()
67 * @deprecated since version 3.4, to be removed in 4.0, inject the list of clearers as a constructor argument instead.
69 public function setWarmers(array $warmers)
71 @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0, inject the list of clearers as a constructor argument instead.', __METHOD__), E_USER_DEPRECATED);
73 $this->warmers = array();
74 foreach ($warmers as $warmer) {
80 * @deprecated since version 3.4, to be removed in 4.0, inject the list of clearers as a constructor argument instead.
82 public function add(CacheWarmerInterface $warmer)
84 if ($this->triggerDeprecation) {
85 @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0, inject the list of clearers as a constructor argument instead.', __METHOD__), E_USER_DEPRECATED);
88 $this->warmers[] = $warmer;