Failed Conditions
Push — ng ( 29d837...4fff42 )
by Florent
03:48
created

FormPostResponseModeSource::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
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\Authorization;
15
16
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
17
use OAuth2Framework\Bundle\Component\Component;
18
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
19
use Symfony\Component\Config\FileLocator;
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
22
class FormPostResponseModeSource implements Component
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function load(array $configs, ContainerBuilder $container)
28
    {
29
        $config = $configs['endpoint']['authorization']['response_mode']['form_post'];
30
        $container->setParameter('oauth2_server.endpoint.authorization.response_mode.form_post.enabled', $config['enabled']);
31
        if (!$config['enabled']) {
32
            return;
33
        }
34
        $container->setParameter('oauth2_server.endpoint.authorization.response_mode.form_post.template', $config['template']);
35
        $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/endpoint/authorization'));
36
        $loader->load('form_post_response_mode.php');
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function name(): string
43
    {
44
        return 'form_post';
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function getNodeDefinition(ArrayNodeDefinition $node, ArrayNodeDefinition $rootNode)
51
    {
52
        $node->children()
53
            ->arrayNode($this->name())
54
                ->canBeEnabled()
55
                ->children()
56
                    ->scalarNode('template')
57
                        ->info('The template used to render the form.')
58
                        ->defaultValue('@OAuth2FrameworkBundle/form_post/response.html.twig')
59
                    ->end()
60
                ->end()
61
            ->end()
62
        ->end();
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function prepend(ContainerBuilder $container, array $config): array
69
    {
70
        return [];
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function build(ContainerBuilder $container)
77
    {
78
    }
79
}
80