Failed Conditions
Push — ng ( fe3ccc...89ffb0 )
by Florent
09:19
created

IssuerDiscoveryEndpointSource::getNodeDefinition()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 24
nc 1
nop 2
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\Bundle\Component\Endpoint\IssuerDiscovery;
15
16
use OAuth2Framework\Bundle\Component\Component;
17
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
18
use Symfony\Component\Config\FileLocator;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
21
22
class IssuerDiscoveryEndpointSource implements Component
23
{
24
    /**
25
     * @return string
26
     */
27
    public function name(): string
28
    {
29
        return 'issuer_discovery';
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function load(array $configs, ContainerBuilder $container)
36
    {
37
        $container->setParameter('oauth2_server.endpoint.issuer_discovery', $configs['endpoint']['issuer_discovery']);
38
39
        $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/endpoint/issuer_discovery'));
40
        $loader->load('issuer_discovery.php');
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function getNodeDefinition(ArrayNodeDefinition $node, ArrayNodeDefinition $rootNode)
47
    {
48
        $node->children()
49
            ->arrayNode($this->name())
50
                ->treatNullLike([])
51
                ->treatFalseLike([])
52
                ->useAttributeAsKey('name')
53
                ->arrayPrototype()
54
                    ->children()
55
                        ->scalarNode('host')
56
                            ->defaultValue('')
57
                        ->end()
58
                        ->scalarNode('path')
59
                            ->isRequired()
60
                        ->end()
61
                        ->scalarNode('resource_repository')
62
                            ->isRequired()
63
                        ->end()
64
                        ->scalarNode('server')
65
                            ->isRequired()
66
                        ->end()
67
                    ->end()
68
                ->end()
69
            ->end()
70
        ->end();
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function build(ContainerBuilder $container)
77
    {
78
        $container->addCompilerPass(new IssuerDiscoveryCompilerPass());
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function prepend(ContainerBuilder $container, array $config): array
85
    {
86
        return [];
87
    }
88
}
89