343e217b9687b461e980cd60a90bc70e9b542e7b
[yaffs-website] / vendor / symfony / http-kernel / DependencyInjection / ControllerArgumentValueResolverPass.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\HttpKernel\DependencyInjection;
13
14 use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
15 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16 use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
17 use Symfony\Component\DependencyInjection\ContainerBuilder;
18
19 /**
20  * Gathers and configures the argument value resolvers.
21  *
22  * @author Iltar van der Berg <kjarli@gmail.com>
23  */
24 class ControllerArgumentValueResolverPass implements CompilerPassInterface
25 {
26     use PriorityTaggedServiceTrait;
27
28     private $argumentResolverService;
29     private $argumentValueResolverTag;
30
31     public function __construct($argumentResolverService = 'argument_resolver', $argumentValueResolverTag = 'controller.argument_value_resolver')
32     {
33         $this->argumentResolverService = $argumentResolverService;
34         $this->argumentValueResolverTag = $argumentValueResolverTag;
35     }
36
37     public function process(ContainerBuilder $container)
38     {
39         if (!$container->hasDefinition($this->argumentResolverService)) {
40             return;
41         }
42
43         $container
44             ->getDefinition($this->argumentResolverService)
45             ->replaceArgument(1, new IteratorArgument($this->findAndSortTaggedServices($this->argumentValueResolverTag, $container)))
46         ;
47     }
48 }