Completed
Push — master ( 3d485f...407dff )
by Paweł
66:49
created

OverrideTemplatesSystemPass::process()   B

Complexity

Conditions 4
Paths 8

Size

Total Lines 26
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 8.5806
c 0
b 0
f 0
cc 4
eloc 17
nc 8
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Core Bundle.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2016 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\CoreBundle\DependencyInjection\Compiler;
16
17
use SWP\Bundle\CoreBundle\Container\RevisionAwareContainerRenderer;
18
use SWP\Bundle\CoreBundle\Factory\ContainerFactory;
19
use SWP\Bundle\CoreBundle\Service\RevisionAwareContainerService;
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
use Symfony\Component\DependencyInjection\Reference;
22
23
final class OverrideTemplatesSystemPass extends AbstractOverridePass
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function process(ContainerBuilder $container)
29
    {
30
        $containerRenderer = $this->getDefinitionIfExists($container, 'swp.factory.container_renderer');
31
        if (null !== $containerRenderer) {
32
            $containerRenderer
33
                ->setArguments([
34
                    RevisionAwareContainerRenderer::class,
35
                ]);
36
        }
37
38
        $containerFactory = $this->getDefinitionIfExists($container, 'swp.factory.container');
39
        if (null !== $containerFactory) {
40
            $containerFactory
41
                ->setClass(ContainerFactory::class)
42
                ->setArguments([
43
                    $container->getParameter('swp.model.container.class'),
44
                    new Reference('swp_multi_tenancy.random_string_generator'),
45
                ]);
46
        }
47
48
        $containerService = $this->getDefinitionIfExists($container, 'swp_template_engine.container.service');
49
        if (null !== $containerService) {
50
            $containerService
51
                ->setClass(RevisionAwareContainerService::class);
52
        }
53
    }
54
}
55