Completed
Push — master ( c8fd93...a9ab00 )
by Georges
01:49
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 26
rs 8.8571
cc 1
eloc 22
nc 1
nop 0
1
<?php
2
3
/**
4
 *
5
 * This file is part of phpFastCache.
6
 *
7
 * @license MIT License (MIT)
8
 *
9
 * For full copyright and license information, please see the docs/CREDITS.txt file.
10
 *
11
 * @author Georges.L (Geolim4)  <[email protected]>
12
 * @author PastisD https://github.com/PastisD
13
 * @author Khoa Bui (khoaofgod)  <[email protected]> http://www.phpfastcache.com
14
 *
15
 */
16
17
namespace phpFastCache\Bundle\DependencyInjection;
18
19
use phpFastCache\CacheManager;
20
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
21
use Symfony\Component\Config\Definition\ConfigurationInterface;
22
23
/**
24
 * Class Configuration
25
 * @package phpFastCache\Bundle\DependencyInjection
26
 */
27
class Configuration implements ConfigurationInterface
28
{
29
    /**
30
     * {@inheritDoc}
31
     *
32
     * @throws \RuntimeException
33
     */
34
    public function getConfigTreeBuilder()
35
    {
36
        $treeBuilder = new TreeBuilder();
37
        $rootNode = $treeBuilder->root('php_fast_cache');
38
39
        $rootNode
40
            ->children()
41
                ->scalarNode('twig_driver')
42
                    ->isRequired()
43
                ->end()
44
                ->booleanNode('twig_block_debug')
45
                    ->defaultFalse()
46
                ->end()
47
                ->arrayNode('drivers')
48
                    ->useAttributeAsKey('name')
49
                    ->prototype('array')
50
                        ->children()
51
                            ->enumNode('type')->isRequired()->values(CacheManager::getStaticAllDrivers())->end() // @TODO : Add all available drivers
52
                            ->arrayNode('parameters')->isRequired()->prototype('variable')->end()
53
                        ->end()
54
                    ->end()
55
                ->end()
56
            ->end();
57
58
        return $treeBuilder;
59
    }
60
}
61