1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the core-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2019 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\CoreBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
15
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Configuration. |
19
|
|
|
* |
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
21
|
|
|
* @package WBW\Bundle\CoreBundle\DependencyInjection |
22
|
|
|
*/ |
23
|
|
|
class Configuration implements ConfigurationInterface { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* {@inheritDoc} |
27
|
|
|
* |
28
|
|
|
* @see https://github.com/webeweb/core-bundle/blob/master/Tests/Fixtures/app/config/config_test.yml |
29
|
|
|
*/ |
30
|
|
|
public function getConfigTreeBuilder() { |
31
|
|
|
|
32
|
|
|
$assets = ConfigurationHelper::loadYamlConfig(__DIR__, "assets"); |
33
|
|
|
$plugins = $assets["assets"]["wbw.core.asset.core"]["plugins"]; |
34
|
|
|
|
35
|
|
|
$treeBuilder = new TreeBuilder(WBWCoreExtension::EXTENSION_ALIAS); |
36
|
|
|
|
37
|
|
|
$rootNode = ConfigurationHelper::getRootNode($treeBuilder, WBWCoreExtension::EXTENSION_ALIAS); |
38
|
|
|
$rootNode |
39
|
|
|
->children() |
40
|
|
|
->booleanNode("commands")->defaultTrue()->info("Load commands")->end() |
41
|
|
|
->booleanNode("event_listeners")->defaultTrue()->info("Load event listeners")->end() |
42
|
|
|
->booleanNode("providers")->defaultTrue()->info("Load providers")->end() |
43
|
|
|
->booleanNode("twig")->defaultTrue()->info("Load Twig extensions")->end() |
44
|
|
|
->arrayNode("quote_providers")->addDefaultsIfNotSet() |
45
|
|
|
->children() |
46
|
|
|
->booleanNode("worlds_wisdom")->defaultFalse()->info("Load World's wisdom")->end() |
47
|
|
|
->end() |
48
|
|
|
->end() |
49
|
|
|
->booleanNode("security_event_listener")->defaultFalse()->info("Load Security event listener")->end() |
50
|
|
|
->arrayNode("plugins")->info("Core plug-ins") |
51
|
|
|
->prototype("scalar") |
52
|
|
|
->validate() |
53
|
|
|
->ifNotInArray(array_keys($plugins)) |
54
|
|
|
->thenInvalid("The Core plug-in %s is not supported. Please choose one of " . json_encode(array_keys($plugins))) |
55
|
|
|
->end() |
56
|
|
|
->end() |
57
|
|
|
->end() |
58
|
|
|
->arrayNode("locales")->addDefaultsIfNotSet() |
59
|
|
|
->children() |
60
|
|
|
->variableNode("jquery_select2")->defaultValue("en")->info("jQuery Select2 locale") |
61
|
|
|
->validate() |
62
|
|
|
->ifNotInArray($plugins["jquery_select2"]["locales"]) |
63
|
|
|
->thenInvalid("The jQuery Select2 locale %s is not supported. Please choose one of " . json_encode($plugins["jquery_select2"]["locales"])) |
64
|
|
|
->end() |
65
|
|
|
->end() |
66
|
|
|
->end() |
67
|
|
|
->end() |
68
|
|
|
->arrayNode("themes")->addDefaultsIfNotSet() |
69
|
|
|
->children() |
70
|
|
|
->variableNode("syntax_highlighter")->defaultValue("Default")->info("SyntaxHighlighter theme") |
71
|
|
|
->validate() |
72
|
|
|
->ifNotInArray($plugins["syntax_highlighter"]["themes"]) |
73
|
|
|
->thenInvalid("The SyntaxHighlighter theme %s is not supported. Please choose one of " . json_encode($plugins["syntax_highlighter"]["themes"])) |
74
|
|
|
->end() |
75
|
|
|
->end() |
76
|
|
|
->end() |
77
|
|
|
->end() |
78
|
|
|
->arrayNode("brushes") |
79
|
|
|
->children() |
80
|
|
|
->arrayNode("syntax_highlighter")->info("SyntaxHighlighter brushes") |
81
|
|
|
->prototype("scalar") |
82
|
|
|
->validate() |
83
|
|
|
->ifNotInArray($plugins["syntax_highlighter"]["brushes"]) |
84
|
|
|
->thenInvalid("The SyntaxHighlighter brush %s is not supported. Please choose one of " . json_encode($plugins["syntax_highlighter"]["brushes"])) |
85
|
|
|
->end() |
86
|
|
|
->end() |
87
|
|
|
->end() |
88
|
|
|
->end() |
89
|
|
|
->end() |
90
|
|
|
->end(); |
91
|
|
|
|
92
|
|
|
return $treeBuilder; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|