Completed
Branch master (c0d8ef)
by Yaroslav
06:36
created

SensioFrameworkExtraBundlePass   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 8
dl 0
loc 20
rs 10
c 0
b 0
f 0
ccs 8
cts 8
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 13 5
1
<?php
2
3
/*
4
 *
5
 * (c) Yaroslav Honcharuk <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Yarhon\RouteGuardBundle\DependencyInjection\Compiler;
12
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Yarhon\RouteGuardBundle\Security\TestProvider\SensioSecurityProvider;
16
use Yarhon\RouteGuardBundle\Security\TestResolver\SensioSecurityResolver;
17
use Yarhon\RouteGuardBundle\Security\Authorization\SensioSecurityExpressionVoter;
18
19
/**
20
 * @author Yaroslav Honcharuk <[email protected]>
21
 */
22
class SensioFrameworkExtraBundlePass implements CompilerPassInterface
23
{
24
    /**
25
     * @see https://github.com/sensiolabs/SensioFrameworkExtraBundle/blob/v5.1.0/Resources/config/security.xml
26
     *
27
     * {@inheritdoc}
28
     */
29 4
    public function process(ContainerBuilder $container)
30
    {
31 4
        if (!$container->hasDefinition('sensio_framework_extra.security.listener') &&
32 4
            !$container->hasDefinition('framework_extra_bundle.event.is_granted')) {
33
34 1
            $container->removeDefinition(SensioSecurityProvider::class);
35 1
            $container->removeDefinition(SensioSecurityResolver::class);
36
        }
37
38 4
        if (!$container->hasDefinition('sensio_framework_extra.security.listener') ||
39 4
            !$container->hasDefinition('sensio_framework_extra.security.expression_language.default')) {
40
41 2
            $container->removeDefinition(SensioSecurityExpressionVoter::class);
42
        }
43 4
    }
44
}
45