Completed
Push — master ( 31c85f...67dec4 )
by San
16s
created

sources/lib/DependencyInjection/Configuration.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/*
3
 * This file is part of the PommProject/PommBundle package.
4
 *
5
 * (c) 2014 Grégoire HUBERT <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PommProject\PommBundle\DependencyInjection;
11
12
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
13
use Symfony\Component\Config\Definition\ConfigurationInterface;
14
15
/**
16
 * Configuration
17
 *
18
 * Configuration manager.
19
 *
20
 * @package PommBundle
21
 * @copyright 2014 Grégoire HUBERT
22
 * @author Nicolas JOSEPH
23
 * @license X11 {@link http://opensource.org/licenses/mit-license.php}
24
 * @see ConfigurationInterface
25
 */
26
class Configuration implements ConfigurationInterface
27
{
28
    /**
29
     * getConfigTreeBuilder
30
     *
31
     * @see ConfigurationInterface
32
     */
33
    public function getConfigTreeBuilder()
34
    {
35
        $treeBuilder = new TreeBuilder();
36
        $rootNode = $treeBuilder->root('pomm');
37
        $rootNode
38
            ->children()
39
                ->arrayNode('configuration')
40
                    ->useAttributeAsKey('key')
41
                    ->requiresAtLeastOneElement()
42
                    ->prototype('array')
43
                        ->children()
44
                            ->scalarNode('dsn')->isRequired()->end()
45
                            ->scalarNode('class:session_builder')
46
                                ->defaultNull()
47
                                ->beforeNormalization()
48
                                    ->always()
49
                                    ->then(function ($v) {
50
                                        @trigger_error('class:session_builder is deprecated since version 2.3 and will be removed in 3.0. Use session_builder config key instead with a service id.', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
51
                                        return $v;
52
                                    })
53
                                ->end()
54
                            ->end()
55
                            ->scalarNode('session_builder')->defaultNull()->end()
56
                            ->scalarNode('pomm:default')->end()
57
                        ->end()
58
                        ->validate()
59
                            ->ifTrue(function ($v) {
60
                                return isset($v['session_builder']) && isset($v['class:session_builder']);
61
                            })
62
                            ->thenInvalid('You cannot use both "session_builder" and "class:session_builder" at the same time.')
63
                        ->end()
64
                        ->beforeNormalization()
65
                            ->always()
66
                            ->then(function ($v) {
67
                                if (!isset($v['session_builder']) && !isset($v['class:session_builder'])) {
68
                                    $v['session_builder'] = 'pomm.model_manager.session_builder';
69
                                }
70
                                return $v;
71
                            })
72
                        ->end()
73
                    ->end()
74
                ->end()
75
                ->arrayNode('logger')
76
                    ->children()
77
                        ->scalarNode('service')->end()
78
                    ->end()
79
                ->end()
80
            ->end();
81
82
        return $treeBuilder;
83
    }
84
}
85