CookieCompilerPass   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 9 2
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