Failed Conditions
Push — ng ( c00098...4b490a )
by Florent
06:57
created

CustomRouteSource::name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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\Metadata;
15
16
use OAuth2Framework\Bundle\Component\Component;
17
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
20
class CustomRouteSource implements Component
21
{
22
    /**
23
     * @return string
24
     */
25
    public function name(): string
26
    {
27
        return 'custom_routes';
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function load(array $configs, ContainerBuilder $container)
34
    {
35
        $container->setParameter('oauth2_server.endpoint.metadata.custom_routes', $configs['endpoint']['metadata']['custom_routes']);
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function getNodeDefinition(NodeDefinition $node)
42
    {
43
        $node->children()
44
            ->arrayNode('custom_routes')
45
                ->info('Custom routes added to the metadata response.')
46
                ->useAttributeAsKey('name')
47
                ->treatNullLike([])
48
                ->treatFalseLike([])
49
                ->prototype('array')
50
                    ->children()
51
                        ->scalarNode('route_name')
52
                            ->info('Route name.')
53
                            ->isRequired()
54
                        ->end()
55
                        ->arrayNode('route_parameters')
56
                            ->info('Parameters associated to the route (if needed).')
57
                            ->useAttributeAsKey('name')
58
                            ->prototype('variable')->end()
59
                            ->treatNullLike([])
60
                        ->end()
61
                    ->end()
62
                ->end()
63
            ->end()
64
        ->end();
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function build(ContainerBuilder $container)
71
    {
72
        //Nothing to do
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function prepend(ContainerBuilder $container, array $config): array
79
    {
80
        return [];
81
    }
82
}
83