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 class CacheWarmerAggregate implements CacheWarmerInterface
21 protected $warmers = array();
22 protected $optionalsEnabled = false;
24 public function __construct(array $warmers = array())
26 foreach ($warmers as $warmer) {
31 public function enableOptionalWarmers()
33 $this->optionalsEnabled = true;
39 * @param string $cacheDir The cache directory
41 public function warmUp($cacheDir)
43 foreach ($this->warmers as $warmer) {
44 if (!$this->optionalsEnabled && $warmer->isOptional()) {
48 $warmer->warmUp($cacheDir);
53 * Checks whether this warmer is optional or not.
55 * @return bool always false
57 public function isOptional()
62 public function setWarmers(array $warmers)
64 $this->warmers = array();
65 foreach ($warmers as $warmer) {
70 public function add(CacheWarmerInterface $warmer)
72 $this->warmers[] = $warmer;