|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the bootstrap-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\BootstrapBundle\DependencyInjection; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
15
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
16
|
|
|
use WBW\Bundle\CoreBundle\DependencyInjection\ConfigurationHelper; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Configuration. |
|
20
|
|
|
* |
|
21
|
|
|
* @author webeweb <https://github.com/webeweb/> |
|
22
|
|
|
* @package WBW\Bundle\BootstrapBundle\DependencyInjection |
|
23
|
|
|
*/ |
|
24
|
|
|
class Configuration implements ConfigurationInterface { |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* {@inheritDoc} |
|
28
|
|
|
*/ |
|
29
|
|
|
public function getConfigTreeBuilder() { |
|
30
|
|
|
|
|
31
|
|
|
$assets = ConfigurationHelper::loadYamlConfig(__DIR__, "assets"); |
|
32
|
|
|
$plugins = $assets["assets"]["wbw.bootstrap.asset.bootstrap"]["plugins"]; |
|
33
|
|
|
|
|
34
|
|
|
$treeBuilder = new TreeBuilder(WBWBootstrapExtension::EXTENSION_ALIAS); |
|
35
|
|
|
|
|
36
|
|
|
$rootNode = ConfigurationHelper::getRootNode($treeBuilder, WBWBootstrapExtension::EXTENSION_ALIAS); |
|
37
|
|
|
$rootNode |
|
38
|
|
|
->children() |
|
39
|
|
|
->booleanNode("twig")->defaultTrue()->info("Load Twig extensions")->end() |
|
40
|
|
|
->integerNode("version")->defaultValue(4)->info("Version")->min(3)->max(5)->end() |
|
41
|
|
|
->arrayNode("plugins")->info("Bootstrap plug-ins") |
|
42
|
|
|
->prototype("scalar") |
|
43
|
|
|
->validate() |
|
44
|
|
|
->ifNotInArray(array_keys($plugins)) |
|
45
|
|
|
->thenInvalid("The Bootstrap plug-in %s is not supported. Please choose one of " . json_encode(array_keys($plugins))) |
|
46
|
|
|
->end() |
|
47
|
|
|
->end() |
|
48
|
|
|
->end() |
|
49
|
|
|
->arrayNode("locales")->addDefaultsIfNotSet() |
|
50
|
|
|
->children() |
|
51
|
|
|
->variableNode("bootstrap_markdown")->defaultValue("en")->info("Bootstrap Markdown locale") |
|
52
|
|
|
->validate() |
|
53
|
|
|
->ifNotInArray($plugins["bootstrap_markdown"]["locales"]) |
|
54
|
|
|
->thenInvalid("The Bootstrap Markdown locale %s is not supported. Please choose one of " . json_encode($plugins["bootstrap_markdown"]["locales"])) |
|
55
|
|
|
->end() |
|
56
|
|
|
->end() |
|
57
|
|
|
->variableNode("bootstrap_wysiwyg")->defaultValue("en-US")->info("Bootstrap WYSIWYG locale") |
|
58
|
|
|
->validate() |
|
59
|
|
|
->ifNotInArray($plugins["bootstrap_wysiwyg"]["locales"]) |
|
60
|
|
|
->thenInvalid("The Bootstrap WYSIWYG locale %s is not supported. Please choose one of " . json_encode($plugins["bootstrap_wysiwyg"]["locales"])) |
|
61
|
|
|
->end() |
|
62
|
|
|
->end() |
|
63
|
|
|
->variableNode("summernote")->defaultValue("en-US")->info("Summernote locale") |
|
64
|
|
|
->validate() |
|
65
|
|
|
->ifNotInArray($plugins["summernote"]["locales"]) |
|
66
|
|
|
->thenInvalid("The Summernote locale %s is not supported. Please choose one of " . json_encode($plugins["summernote"]["locales"])) |
|
67
|
|
|
->end() |
|
68
|
|
|
->end() |
|
69
|
|
|
->end() |
|
70
|
|
|
->end() |
|
71
|
|
|
->end(); |
|
72
|
|
|
|
|
73
|
|
|
return $treeBuilder; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
|