Failed Conditions
Push — master ( 7b0e20...7a5b0d )
by Florent
27:20 queued 25:10
created

AbstractJWKSetSource::addConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 9
nc 1
nop 1
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace SpomkyLabs\JoseBundle\DependencyInjection\Source\JWKSetSource;
13
14
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
15
use SpomkyLabs\JoseBundle\DependencyInjection\Source\AbstractSource;
16
17
abstract class AbstractJWKSetSource extends AbstractSource implements JWKSetSourceInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function create(ContainerBuilder $container, $id, array $config)
23
    {
24
        parent::create($container, $id, $config);
25
        
26
        if ($config['is_shared']) {
27
            $controller_definition = new Definition('SpomkyLabs\JoseBundle\Controller\JWKSetController');
28
            $controller_definition->setFactory([new Reference('jose.controller.jwkset_controllery_factory'), 'createJWKSetController']);
29
            $controller_definition->setArguments([new Reference($id)]);
30
            $container->setDefinition('jose.controller.'.$id, $controller_definition);
31
        }
32
    }
33
    
34
    /**
35
     * @param \Symfony\Component\Config\Definition\Builder\NodeDefinition $node
36
     */
37
    public function addConfiguration(NodeDefinition $node)
38
    {
39
        parent::addConfiguration($node);
40
        $node
41
            ->children()
42
                ->booleanNode('is_shared')
43
                    ->info('If true, a controller will be created to ease the JWKSet to be shared.')
44
                    ->defaultFalse()
45
                ->end()
46
            ->end();
47
    }
48
}
49