Completed
Push — master ( c3ce72...f2565d )
by Paweł
20s
created

OverrideHateoasTwigHelperPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 14 4
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Core Bundle.
5
 *
6
 * Copyright 2017 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 2017 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\CoreBundle\DependencyInjection\Compiler;
16
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
19
final class OverrideHateoasTwigHelperPass extends AbstractOverridePass
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function process(ContainerBuilder $container)
25
    {
26
        $twig = $this->getDefinitionIfExists($container, 'twig');
27
        $methodCalls = $twig->getMethodCalls();
28
        foreach ($twig->getMethodCalls() as $key => $references) {
29
            if ('addExtension' === $references[0] && 'hateoas.twig.link' === $references[1][0]->__toString()) {
30
                unset($methodCalls[$key]);
31
            }
32
        }
33
        $twig->setMethodCalls($methodCalls);
34
        $hateoas = $this->getDefinitionIfExists($container, 'hateoas.twig.link');
35
        $hateoas->clearTags();
36
        $container->removeDefinition('hateoas.twig.link');
37
    }
38
}
39