AddExpressionLanguageProvidersPass.php 1.3 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\Bundle\SecurityBundle\DependencyInjection\Compiler;
  11. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. use Symfony\Component\DependencyInjection\Reference;
  14. /**
  15. * Registers the expression language providers.
  16. *
  17. * @author Fabien Potencier <fabien@symfony.com>
  18. */
  19. class AddExpressionLanguageProvidersPass implements CompilerPassInterface
  20. {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function process(ContainerBuilder $container)
  25. {
  26. if ($container->has('security.expression_language')) {
  27. $definition = $container->findDefinition('security.expression_language');
  28. foreach ($container->findTaggedServiceIds('security.expression_language_provider', true) as $id => $attributes) {
  29. $definition->addMethodCall('registerProvider', [new Reference($id)]);
  30. }
  31. }
  32. if (!$container->hasDefinition('cache.system')) {
  33. $container->removeDefinition('cache.security_expression_language');
  34. }
  35. }
  36. }