Нема описа

Psr6CacheClearer.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. * @author Nicolas Grekas <p@tchwork.com>
  13. */
  14. class Psr6CacheClearer implements CacheClearerInterface
  15. {
  16. private $pools = [];
  17. public function __construct(array $pools = [])
  18. {
  19. $this->pools = $pools;
  20. }
  21. public function hasPool($name)
  22. {
  23. return isset($this->pools[$name]);
  24. }
  25. public function getPool($name)
  26. {
  27. if (!$this->hasPool($name)) {
  28. throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name));
  29. }
  30. return $this->pools[$name];
  31. }
  32. public function clearPool($name)
  33. {
  34. if (!isset($this->pools[$name])) {
  35. throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name));
  36. }
  37. return $this->pools[$name]->clear();
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function clear($cacheDir)
  43. {
  44. foreach ($this->pools as $pool) {
  45. $pool->clear();
  46. }
  47. }
  48. }