CookieCompilerPass::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
rs 9.6666
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
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 ONGR\CookiesBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
/**
19
 * Finds all services tagged with 'cookie' tag and adds them to cookie factory.
20
 */
21
class CookieCompilerPass implements CompilerPassInterface
22
{
23
    /**
24
     * Finds all services tagged with 'cookie' tag and adds them to cookie factory.
25
     *
26
     * @param ContainerBuilder $container
27
     */
28
    public function process(ContainerBuilder $container)
29
    {
30
        $taggedServices = $container->findTaggedServiceIds('ongr_cookie.cookie');
31
        $injectorDefinition = $container->getDefinition('ongr_cookie.injector');
32
33
        foreach ($taggedServices as $id => $tagAttributes) {
34
            $injectorDefinition->addMethodCall('addCookieModel', [new Reference($id)]);
35
        }
36
    }
37
}
38