Chris@14
|
1 <?php
|
Chris@14
|
2
|
Chris@14
|
3 /*
|
Chris@14
|
4 * This file is part of the Symfony package.
|
Chris@14
|
5 *
|
Chris@14
|
6 * (c) Fabien Potencier <fabien@symfony.com>
|
Chris@14
|
7 *
|
Chris@14
|
8 * For the full copyright and license information, please view the LICENSE
|
Chris@14
|
9 * file that was distributed with this source code.
|
Chris@14
|
10 */
|
Chris@14
|
11
|
Chris@14
|
12 namespace Symfony\Component\Routing\DependencyInjection;
|
Chris@14
|
13
|
Chris@14
|
14 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
Chris@14
|
15 use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
|
Chris@17
|
16 use Symfony\Component\DependencyInjection\ContainerBuilder;
|
Chris@17
|
17 use Symfony\Component\DependencyInjection\Reference;
|
Chris@14
|
18
|
Chris@14
|
19 /**
|
Chris@14
|
20 * Adds tagged routing.loader services to routing.resolver service.
|
Chris@14
|
21 *
|
Chris@14
|
22 * @author Fabien Potencier <fabien@symfony.com>
|
Chris@14
|
23 */
|
Chris@14
|
24 class RoutingResolverPass implements CompilerPassInterface
|
Chris@14
|
25 {
|
Chris@14
|
26 use PriorityTaggedServiceTrait;
|
Chris@14
|
27
|
Chris@14
|
28 private $resolverServiceId;
|
Chris@14
|
29 private $loaderTag;
|
Chris@14
|
30
|
Chris@14
|
31 public function __construct($resolverServiceId = 'routing.resolver', $loaderTag = 'routing.loader')
|
Chris@14
|
32 {
|
Chris@14
|
33 $this->resolverServiceId = $resolverServiceId;
|
Chris@14
|
34 $this->loaderTag = $loaderTag;
|
Chris@14
|
35 }
|
Chris@14
|
36
|
Chris@14
|
37 public function process(ContainerBuilder $container)
|
Chris@14
|
38 {
|
Chris@14
|
39 if (false === $container->hasDefinition($this->resolverServiceId)) {
|
Chris@14
|
40 return;
|
Chris@14
|
41 }
|
Chris@14
|
42
|
Chris@14
|
43 $definition = $container->getDefinition($this->resolverServiceId);
|
Chris@14
|
44
|
Chris@14
|
45 foreach ($this->findAndSortTaggedServices($this->loaderTag, $container) as $id) {
|
Chris@17
|
46 $definition->addMethodCall('addLoader', [new Reference($id)]);
|
Chris@14
|
47 }
|
Chris@14
|
48 }
|
Chris@14
|
49 }
|