AddAnnotationsCachedReaderPass.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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\Bundle\FrameworkBundle\DependencyInjection\Compiler;
  11. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. /**
  14. * @internal
  15. */
  16. class AddAnnotationsCachedReaderPass implements CompilerPassInterface
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public function process(ContainerBuilder $container)
  22. {
  23. // "annotations.cached_reader" is wired late so that any passes using
  24. // "annotation_reader" at build time don't get any cache
  25. foreach ($container->findTaggedServiceIds('annotations.cached_reader') as $id => $tags) {
  26. $reader = $container->getDefinition($id);
  27. $properties = $reader->getProperties();
  28. if (isset($properties['cacheProviderBackup'])) {
  29. $provider = $properties['cacheProviderBackup']->getValues()[0];
  30. unset($properties['cacheProviderBackup']);
  31. $reader->setProperties($properties);
  32. $container->set($id, null);
  33. $container->setDefinition($id, $reader->replaceArgument(1, $provider));
  34. }
  35. }
  36. }
  37. }