This repository was archived by the owner on Apr 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConfiguration.php
More file actions
93 lines (81 loc) · 2.84 KB
/
Configuration.php
File metadata and controls
93 lines (81 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* This file is part of Gitonomy.
*
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
* (c) Julien DIDIER <genzo.wm@gmail.com>
*
* This source file is subject to the GPL license that is bundled
* with this source code in the file LICENSE.
*/
namespace Gitonomy\Bundle\GitBundle\DependencyInjection;
use Gitonomy\Bundle\GitBundle\Routing\AbstractGitUrlGenerator;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* Configuration of the Gitonomy core bundle.
*
* @author Alexandre Salomé <alexandre.salome@gmail.com>
*/
class Configuration implements ConfigurationInterface
{
const DEFAULT_THEME = 'GitonomyGitBundle::default_theme.html.twig';
/**
* @inheritdoc
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('gitonomy_twig');
$current = $rootNode
->children()
->booleanNode('profiler')->defaultFalse()->end()
->arrayNode('twig_extension')
->beforeNormalization()
->ifTrue()
->then(function () { return array('enabled' => true); })
->end()
->addDefaultsIfNotSet()
->children()
->booleanNode('enabled')->defaultFalse()->end()
->booleanNode('profiler')->defaultFalse()->end()
->arrayNode('routes_names')
->addDefaultsIfNotSet()
->children()
;
foreach (AbstractGitUrlGenerator::getRouteNames() as $name => $value) {
$current->scalarNode($name)->defaultValue($value)->end();
}
$current = $current
->end()
->end()
->arrayNode('routes_args')
->addDefaultsIfNotSet()
->children()
;
foreach (AbstractGitUrlGenerator::getRouteArgs() as $name => $value) {
$current->scalarNode($name)->defaultValue($value)->end();
}
$current
->end()
->end()
->arrayNode('themes')
->normalizeKeys(false)
->useAttributeAsKey('key')
->beforeNormalization()
->always(function ($e) {
if (!in_array(self::DEFAULT_THEME, $e)) {
$e[] = self::DEFAULT_THEME;
}
return $e;
})
->end()
->defaultValue(array(self::DEFAULT_THEME))
->prototype('scalar')
->end()
->end()
->end()
;
return $treeBuilder;
}
}