Completed
Pull Request — master (#170)
by Simonas
03:06
created

SettingsManagerPass::process()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 21
rs 9.3142
cc 1
eloc 13
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 Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Definition;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
class SettingsManagerPass implements CompilerPassInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function process(ContainerBuilder $container)
25
    {
26
        $repo = $container->getParameter('ongr_settings.repo');
27
        $filterManager = new Definition('ONGR\FilterManagerBundle\Search\FilterManager', [
28
            new Reference('ongr_settings.filter_container'),
29
            new Reference($repo)
30
        ]);
31
32
        $container->setDefinition('ongr_filter_manager.settings', $filterManager);
33
34
        $settingsManager = new Definition('ONGR\SettingsBundle\Service\SettingsManager', [
35
            new Reference($repo),
36
            new Reference('event_dispatcher')
37
        ]);
38
39
        $settingsManager->addMethodCall('setActiveProfilesSettingName', ['%ongr_settings.active_profiles%']);
40
        $settingsManager->addMethodCall('setActiveProfilesCookie', [new Reference('ongr_settings.cookie.active_profiles')]);
41
        $settingsManager->addMethodCall('setCache', [new Reference('ong_settings.cache_provider')]);
42
43
        $container->setDefinition('ongr_settings.settings_manager', $settingsManager);
44
    }
45
}