SettingsManagerPass::process()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 34
rs 8.8571
cc 1
eloc 20
nc 1
nop 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