Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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
use Symfony\Component\DependencyInjection\Reference;
19
use Symfony\Component\HttpKernel\Controller\ArgumentResolver\TraceableValueResolver;
20
use Symfony\Component\Stopwatch\Stopwatch;
21
 
22
/**
23
 * Gathers and configures the argument value resolvers.
24
 *
25
 * @author Iltar van der Berg <kjarli@gmail.com>
26
 */
27
class ControllerArgumentValueResolverPass implements CompilerPassInterface
28
{
29
    use PriorityTaggedServiceTrait;
30
 
31
    public function process(ContainerBuilder $container)
32
    {
33
        if (!$container->hasDefinition('argument_resolver')) {
34
            return;
35
        }
36
 
37
        $resolvers = $this->findAndSortTaggedServices('controller.argument_value_resolver', $container);
38
 
39
        if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class) && $container->has('debug.stopwatch')) {
40
            foreach ($resolvers as $resolverReference) {
41
                $id = (string) $resolverReference;
42
                $container->register("debug.$id", TraceableValueResolver::class)
43
                    ->setDecoratedService($id)
44
                    ->setArguments([new Reference("debug.$id.inner"), new Reference('debug.stopwatch')]);
45
            }
46
        }
47
 
48
        $container
49
            ->getDefinition('argument_resolver')
50
            ->replaceArgument(1, new IteratorArgument($resolvers))
51
        ;
52
    }
53
}