4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Routing\DependencyInjection;
14 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15 use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
16 use Symfony\Component\DependencyInjection\ContainerBuilder;
17 use Symfony\Component\DependencyInjection\Reference;
20 * Adds tagged routing.loader services to routing.resolver service.
22 * @author Fabien Potencier <fabien@symfony.com>
24 class RoutingResolverPass implements CompilerPassInterface
26 use PriorityTaggedServiceTrait;
28 private $resolverServiceId;
31 public function __construct($resolverServiceId = 'routing.resolver', $loaderTag = 'routing.loader')
33 $this->resolverServiceId = $resolverServiceId;
34 $this->loaderTag = $loaderTag;
37 public function process(ContainerBuilder $container)
39 if (false === $container->hasDefinition($this->resolverServiceId)) {
43 $definition = $container->getDefinition($this->resolverServiceId);
45 foreach ($this->findAndSortTaggedServices($this->loaderTag, $container) as $id) {
46 $definition->addMethodCall('addLoader', array(new Reference($id)));