菜谱项目

ChainCacheClearer.php 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. }