|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Disclaimer: This source code is protected by copyright law and by |
|
5
|
|
|
* international conventions. |
|
6
|
|
|
* |
|
7
|
|
|
* Any reproduction or partial or total distribution of the source code, by any |
|
8
|
|
|
* means whatsoever, is strictly forbidden. |
|
9
|
|
|
* |
|
10
|
|
|
* Anyone not complying with these provisions will be guilty of the offense of |
|
11
|
|
|
* infringement and the penal sanctions provided for by law. |
|
12
|
|
|
* |
|
13
|
|
|
* (c) 2019 All rights reserved. |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace WBW\Bundle\JQuery\QueryBuilderBundle\DependencyInjection; |
|
17
|
|
|
|
|
18
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
19
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
20
|
|
|
use WBW\Bundle\CoreBundle\DependencyInjection\ConfigurationHelper; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Configuration. |
|
24
|
|
|
* |
|
25
|
|
|
* @author webeweb <https://github.com/webeweb/> |
|
26
|
|
|
* @package WBW\Bundle\JQuery\QueryBuilderBundle\DependencyInjection |
|
27
|
|
|
*/ |
|
28
|
|
|
class Configuration implements ConfigurationInterface { |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* {@inheritDoc} |
|
32
|
|
|
*/ |
|
33
|
|
|
public function getConfigTreeBuilder(): TreeBuilder { |
|
34
|
|
|
|
|
35
|
|
|
$assets = ConfigurationHelper::loadYamlConfig(__DIR__, "assets"); |
|
36
|
|
|
$locales = $assets["assets"]["wbw.jquery_querybuilder.asset.jquery_querybuilder"]["locales"]; |
|
37
|
|
|
$themes = $assets["assets"]["wbw.jquery_querybuilder.asset.jquery_querybuilder"]["themes"]; |
|
38
|
|
|
|
|
39
|
|
|
$treeBuilder = new TreeBuilder(WBWJQueryQueryBuilderExtension::EXTENSION_ALIAS); |
|
40
|
|
|
|
|
41
|
|
|
$rootNode = ConfigurationHelper::getRootNode($treeBuilder, WBWJQueryQueryBuilderExtension::EXTENSION_ALIAS); |
|
42
|
|
|
$rootNode |
|
43
|
|
|
->children() |
|
44
|
|
|
->variableNode("locale")->defaultValue("en")->info("jQuery QueryBuilder locale") |
|
45
|
|
|
->validate() |
|
46
|
|
|
->ifNotInArray($locales) |
|
47
|
|
|
->thenInvalid("The jQuery QueryBuilder locale %s is not supported. Please choose one of " . json_encode($locales)) |
|
48
|
|
|
->end() |
|
49
|
|
|
->end() |
|
50
|
|
|
->variableNode("theme")->defaultValue("default")->info("jQuery QueryBuilder theme") |
|
51
|
|
|
->validate() |
|
52
|
|
|
->ifNotInArray($themes) |
|
53
|
|
|
->thenInvalid("The jQuery QueryBuilder theme %s is not supported. Please choose one of " . json_encode($themes)) |
|
54
|
|
|
->end() |
|
55
|
|
|
->end() |
|
56
|
|
|
->end(); |
|
57
|
|
|
|
|
58
|
|
|
return $treeBuilder; |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|