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\HttpKernel\DependencyInjection;
|
Chris@14
|
13
|
Chris@14
|
14 use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
Chris@14
|
15 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
Chris@14
|
16 use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
|
Chris@14
|
17 use Symfony\Component\DependencyInjection\ContainerBuilder;
|
Chris@14
|
18
|
Chris@14
|
19 /**
|
Chris@14
|
20 * Gathers and configures the argument value resolvers.
|
Chris@14
|
21 *
|
Chris@14
|
22 * @author Iltar van der Berg <kjarli@gmail.com>
|
Chris@14
|
23 */
|
Chris@14
|
24 class ControllerArgumentValueResolverPass implements CompilerPassInterface
|
Chris@14
|
25 {
|
Chris@14
|
26 use PriorityTaggedServiceTrait;
|
Chris@14
|
27
|
Chris@14
|
28 private $argumentResolverService;
|
Chris@14
|
29 private $argumentValueResolverTag;
|
Chris@14
|
30
|
Chris@14
|
31 public function __construct($argumentResolverService = 'argument_resolver', $argumentValueResolverTag = 'controller.argument_value_resolver')
|
Chris@14
|
32 {
|
Chris@14
|
33 $this->argumentResolverService = $argumentResolverService;
|
Chris@14
|
34 $this->argumentValueResolverTag = $argumentValueResolverTag;
|
Chris@14
|
35 }
|
Chris@14
|
36
|
Chris@14
|
37 public function process(ContainerBuilder $container)
|
Chris@14
|
38 {
|
Chris@14
|
39 if (!$container->hasDefinition($this->argumentResolverService)) {
|
Chris@14
|
40 return;
|
Chris@14
|
41 }
|
Chris@14
|
42
|
Chris@14
|
43 $container
|
Chris@14
|
44 ->getDefinition($this->argumentResolverService)
|
Chris@14
|
45 ->replaceArgument(1, new IteratorArgument($this->findAndSortTaggedServices($this->argumentValueResolverTag, $container)))
|
Chris@14
|
46 ;
|
Chris@14
|
47 }
|
Chris@14
|
48 }
|