ChainCacheClearer.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. * @final since version 3.4
  17. */
  18. class ChainCacheClearer implements CacheClearerInterface
  19. {
  20. protected $clearers;
  21. /**
  22. * Constructs a new instance of ChainCacheClearer.
  23. *
  24. * @param array $clearers The initial clearers
  25. */
  26. public function __construct($clearers = array())
  27. {
  28. $this->clearers = $clearers;
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function clear($cacheDir)
  34. {
  35. foreach ($this->clearers as $clearer) {
  36. $clearer->clear($cacheDir);
  37. }
  38. }
  39. /**
  40. * Adds a cache clearer to the aggregate.
  41. *
  42. * @deprecated since version 3.4, to be removed in 4.0, inject the list of clearers as a constructor argument instead.
  43. */
  44. public function add(CacheClearerInterface $clearer)
  45. {
  46. @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);
  47. $this->clearers[] = $clearer;
  48. }
  49. }