Failed Conditions
Push — master ( cccd95...989cb2 )
by Florent
03:57
created

OAuth2FrameworkSecurityBundle::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\SecurityBundle;
15
16
use OAuth2Framework\SecurityBundle\DependencyInjection\Compiler\AccessTokenHandlerCompilerPass;
17
use OAuth2Framework\SecurityBundle\DependencyInjection\Compiler\SecurityAnnotationCheckerCompilerPass;
18
use OAuth2Framework\SecurityBundle\DependencyInjection\OAuth2Extension;
19
use OAuth2Framework\SecurityBundle\Security\Factory\OAuth2SecurityFactory;
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
use Symfony\Component\HttpKernel\Bundle\Bundle;
22
23
class OAuth2FrameworkSecurityBundle extends Bundle
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function getContainerExtension()
29
    {
30
        return new OAuth2Extension('oauth2_security');
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function build(ContainerBuilder $container)
37
    {
38
        parent::build($container);
39
        /** @var \Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension $extension */
40
        $extension = $container->getExtension('security');
41
        $extension->addSecurityListenerFactory(new OAuth2SecurityFactory());
42
43
        $container->addCompilerPass(new SecurityAnnotationCheckerCompilerPass());
44
        $container->addCompilerPass(new AccessTokenHandlerCompilerPass());
45
    }
46
}
47