8ee4275b1686746ac9117fd970d989b7d62b06ef
[yaffs-website] / vendor / symfony / http-kernel / CacheClearer / ChainCacheClearer.php
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\CacheClearer;
13
14 /**
15  * ChainCacheClearer.
16  *
17  * @author Dustin Dobervich <ddobervich@gmail.com>
18  *
19  * @final since version 3.4
20  */
21 class ChainCacheClearer implements CacheClearerInterface
22 {
23     protected $clearers;
24
25     /**
26      * Constructs a new instance of ChainCacheClearer.
27      *
28      * @param array $clearers The initial clearers
29      */
30     public function __construct($clearers = array())
31     {
32         $this->clearers = $clearers;
33     }
34
35     /**
36      * {@inheritdoc}
37      */
38     public function clear($cacheDir)
39     {
40         foreach ($this->clearers as $clearer) {
41             $clearer->clear($cacheDir);
42         }
43     }
44
45     /**
46      * Adds a cache clearer to the aggregate.
47      *
48      * @deprecated since version 3.4, to be removed in 4.0, inject the list of clearers as a constructor argument instead.
49      */
50     public function add(CacheClearerInterface $clearer)
51     {
52         @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);
53
54         $this->clearers[] = $clearer;
55     }
56 }