Failed Conditions
Push — master ( 4b5d02...3af7eb )
by Florent
04:35
created

continueConfiguration()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 11
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 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\Server\DependencyInjection\Source\Endpoint;
15
16
use Fluent\PhpConfigFileLoader;
17
use OAuth2Framework\Bundle\Server\DependencyInjection\Source\ActionableSource;
18
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
19
use Symfony\Component\Config\FileLocator;
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
22
final class AuthorizationEndpointPreConfiguredAuthorizationSource extends ActionableSource
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    protected function continueLoading(string $path, ContainerBuilder $container, array $config)
28
    {
29
        $container->setAlias($path.'.event_store', $config['event_store']);
30
31
        $loader = new PhpConfigFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/endpoint'));
32
        $loader->load('pre_configured_authorization.php');
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    protected function name(): string
39
    {
40
        return 'pre_configured_authorization';
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    protected function continueConfiguration(NodeDefinition $node)
47
    {
48
        parent::continueConfiguration($node);
49
        $node
50
            ->validate()
51
                ->ifTrue(function ($config) {
52
                    return true === $config['enabled'] && empty($config['event_store']);
53
                })
54
                ->thenInvalid('The option "event_store" must be set.')
55
            ->end()
56
            ->children()
57
                ->scalarNode('event_store')->defaultNull()->end()
58
            ->end();
59
    }
60
}
61