ChainCacheClearer.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. protected $clearers;
  19. /**
  20. * Constructs a new instance of ChainCacheClearer.
  21. *
  22. * @param array $clearers The initial clearers
  23. */
  24. public function __construct(array $clearers = array())
  25. {
  26. $this->clearers = $clearers;
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function clear($cacheDir)
  32. {
  33. foreach ($this->clearers as $clearer) {
  34. $clearer->clear($cacheDir);
  35. }
  36. }
  37. /**
  38. * Adds a cache clearer to the aggregate.
  39. */
  40. public function add(CacheClearerInterface $clearer)
  41. {
  42. $this->clearers[] = $clearer;
  43. }
  44. }