SettingsManagerPass   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 34 1
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\SettingsBundle\DependencyInjection\Compiler;
13
14
use ONGR\FilterManagerBundle\DependencyInjection\ONGRFilterManagerExtension;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Definition;
18
use Symfony\Component\DependencyInjection\Reference;
19
20
class SettingsManagerPass implements CompilerPassInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function process(ContainerBuilder $container)
26
    {
27
        $repo = $container->getParameter('ongr_settings.repo');
28
        $filterManager = new Definition('ONGR\FilterManagerBundle\Search\FilterManager', [
29
            new Reference('ongr_settings.filter_container'),
30
            new Reference($repo),
31
            new Reference('event_dispatcher')
32
        ]);
33
34
        $container->setDefinition(ONGRFilterManagerExtension::getFilterManagerId('settings'), $filterManager);
35
36
        $settingsManager = new Definition('ONGR\SettingsBundle\Service\SettingsManager', [
37
            new Reference($repo),
38
            new Reference('event_dispatcher')
39
        ]);
40
41
        $settingsManager->addMethodCall('setActiveProfilesSettingName', ['%ongr_settings.active_profiles%']);
42
        $settingsManager->addMethodCall('setActiveExperimentsSettingName', ['%ongr_settings.active_experiments%']);
43
        $settingsManager->addMethodCall(
44
            'setActiveProfilesCookie',
45
            [
46
                new Reference('ongr_settings.cookie.active_profiles')
47
            ]
48
        );
49
        $settingsManager->addMethodCall(
50
            'setActiveExperimentProfilesCookie',
51
            [
52
                new Reference('ongr_settings.cookie.active_experiments')
53
            ]
54
        );
55
        $settingsManager->addMethodCall('setCache', [new Reference('ong_settings.cache_provider')]);
56
57
        $container->setDefinition('ongr_settings.settings_manager', $settingsManager);
58
    }
59
}
60