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\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Reference;
18
 
19
/**
20
 * Register all services that have the "kernel.locale_aware" tag into the listener.
21
 *
22
 * @author Pierre Bobiet <pierrebobiet@gmail.com>
23
 */
24
class RegisterLocaleAwareServicesPass implements CompilerPassInterface
25
{
26
    public function process(ContainerBuilder $container)
27
    {
28
        if (!$container->hasDefinition('locale_aware_listener')) {
29
            return;
30
        }
31
 
32
        $services = [];
33
 
34
        foreach ($container->findTaggedServiceIds('kernel.locale_aware') as $id => $tags) {
35
            $services[] = new Reference($id);
36
        }
37
 
38
        if (!$services) {
39
            $container->removeDefinition('locale_aware_listener');
40
 
41
            return;
42
        }
43
 
44
        $container
45
            ->getDefinition('locale_aware_listener')
46
            ->setArgument(0, new IteratorArgument($services))
47
        ;
48
    }
49
}