CachePoolClearerPass.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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\Cache\DependencyInjection;
  11. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. use Symfony\Component\DependencyInjection\Reference;
  14. /**
  15. * @author Nicolas Grekas <p@tchwork.com>
  16. */
  17. class CachePoolClearerPass implements CompilerPassInterface
  18. {
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public function process(ContainerBuilder $container)
  23. {
  24. $container->getParameterBag()->remove('cache.prefix.seed');
  25. foreach ($container->findTaggedServiceIds('cache.pool.clearer') as $id => $attr) {
  26. $clearer = $container->getDefinition($id);
  27. $pools = [];
  28. foreach ($clearer->getArgument(0) as $name => $ref) {
  29. if ($container->hasDefinition($ref)) {
  30. $pools[$name] = new Reference($ref);
  31. }
  32. }
  33. $clearer->replaceArgument(0, $pools);
  34. }
  35. }
  36. }