ChainCacheClearer.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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\HttpKernel\CacheClearer;
  11. /**
  12. * ChainCacheClearer.
  13. *
  14. * @author Dustin Dobervich <ddobervich@gmail.com>
  15. */
  16. class ChainCacheClearer implements CacheClearerInterface
  17. {
  18. /**
  19. * @var array $clearers
  20. */
  21. protected $clearers;
  22. /**
  23. * Constructs a new instance of ChainCacheClearer.
  24. *
  25. * @param array $clearers The initial clearers.
  26. */
  27. public function __construct(array $clearers = array())
  28. {
  29. $this->clearers = $clearers;
  30. }
  31. /**
  32. * {@inheritDoc}
  33. */
  34. public function clear($cacheDir)
  35. {
  36. foreach ($this->clearers as $clearer) {
  37. $clearer->clear($cacheDir);
  38. }
  39. }
  40. /**
  41. * Adds a cache clearer to the aggregate.
  42. *
  43. * @param CacheClearerInterface $clearer
  44. */
  45. public function add(CacheClearerInterface $clearer)
  46. {
  47. $this->clearers[] = $clearer;
  48. }
  49. }