Completed
Push — master ( 2ae6ae...28d798 )
by Paweł
22s queued 12s
created

OverrideAssetLocationResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 31
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 25 2
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\Resolver\AssetLocationResolver;
18
use SWP\Bundle\CoreBundle\Resolver\AuthorAssetLocationResolver;
19
use SWP\Bundle\CoreBundle\Resolver\SeoAssetLocationResolver;
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
use Symfony\Component\DependencyInjection\Reference;
22
23
final class OverrideAssetLocationResolver extends AbstractOverridePass
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function process(ContainerBuilder $container)
29
    {
30
        $assetLocationResolverDefinition = $this->getDefinitionIfExists($container, 'swp.resolver.asset_location');
31
        if (null !== $assetLocationResolverDefinition) {
32
            $assetLocationResolverDefinition
33
                ->setClass(AssetLocationResolver::class)
34
                ->addMethodCall('setTenantContext', [new Reference('swp_multi_tenancy.tenant_context')]);
35
36
            $authorAssetLocationResolverDefinition = $this->getDefinitionIfExists($container, 'swp.resolver.author_asset_location');
37
            $authorAssetLocationResolverDefinition
38
                ->setClass(AuthorAssetLocationResolver::class)
39
                ->setArguments($assetLocationResolverDefinition->getArguments())
40
                ->addMethodCall('setTenantContext', [new Reference('swp_multi_tenancy.tenant_context')])
41
                ->setPublic(true)
42
            ;
43
44
            $authorAssetLocationResolverDefinition = $this->getDefinitionIfExists($container, 'swp.resolver.seo_asset_location');
45
            $authorAssetLocationResolverDefinition
46
                ->setClass(SeoAssetLocationResolver::class)
47
                ->setArguments($assetLocationResolverDefinition->getArguments())
48
                ->addMethodCall('setTenantContext', [new Reference('swp_multi_tenancy.tenant_context')])
49
                ->setPublic(true)
50
            ;
51
        }
52
    }
53
}
54