Chris@14: Chris@14: * Chris@14: * For the full copyright and license information, please view the LICENSE Chris@14: * file that was distributed with this source code. Chris@14: */ Chris@14: Chris@14: namespace Symfony\Component\Routing\DependencyInjection; Chris@14: Chris@14: use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; Chris@14: use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait; Chris@17: use Symfony\Component\DependencyInjection\ContainerBuilder; Chris@17: use Symfony\Component\DependencyInjection\Reference; Chris@14: Chris@14: /** Chris@14: * Adds tagged routing.loader services to routing.resolver service. Chris@14: * Chris@14: * @author Fabien Potencier Chris@14: */ Chris@14: class RoutingResolverPass implements CompilerPassInterface Chris@14: { Chris@14: use PriorityTaggedServiceTrait; Chris@14: Chris@14: private $resolverServiceId; Chris@14: private $loaderTag; Chris@14: Chris@14: public function __construct($resolverServiceId = 'routing.resolver', $loaderTag = 'routing.loader') Chris@14: { Chris@14: $this->resolverServiceId = $resolverServiceId; Chris@14: $this->loaderTag = $loaderTag; Chris@14: } Chris@14: Chris@14: public function process(ContainerBuilder $container) Chris@14: { Chris@14: if (false === $container->hasDefinition($this->resolverServiceId)) { Chris@14: return; Chris@14: } Chris@14: Chris@14: $definition = $container->getDefinition($this->resolverServiceId); Chris@14: Chris@14: foreach ($this->findAndSortTaggedServices($this->loaderTag, $container) as $id) { Chris@17: $definition->addMethodCall('addLoader', [new Reference($id)]); Chris@14: } Chris@14: } Chris@14: }