RoutingResolverPass.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\Routing\DependencyInjection;
  11. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  12. use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
  13. use Symfony\Component\DependencyInjection\ContainerBuilder;
  14. use Symfony\Component\DependencyInjection\Reference;
  15. /**
  16. * Adds tagged routing.loader services to routing.resolver service.
  17. *
  18. * @author Fabien Potencier <fabien@symfony.com>
  19. */
  20. class RoutingResolverPass implements CompilerPassInterface
  21. {
  22. use PriorityTaggedServiceTrait;
  23. /**
  24. * @return void
  25. */
  26. public function process(ContainerBuilder $container)
  27. {
  28. if (false === $container->hasDefinition('routing.resolver')) {
  29. return;
  30. }
  31. $definition = $container->getDefinition('routing.resolver');
  32. foreach ($this->findAndSortTaggedServices('routing.loader', $container) as $id) {
  33. $definition->addMethodCall('addLoader', [new Reference($id)]);
  34. }
  35. }
  36. }