|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace LAG\AdminBundle\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
|
6
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
|
7
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
8
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
9
|
|
|
|
|
10
|
|
|
class Configuration implements ConfigurationInterface |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @return TreeBuilder |
|
14
|
|
|
*/ |
|
15
|
|
|
public function getConfigTreeBuilder() |
|
16
|
|
|
{ |
|
17
|
|
|
$treeBuilder = new TreeBuilder(); |
|
18
|
|
|
$rootNode = $treeBuilder->root('lag_admin'); |
|
19
|
|
|
|
|
20
|
|
|
$rootNode |
|
21
|
|
|
->children() |
|
22
|
|
|
// application configuration |
|
23
|
|
|
->append($this->getApplicationNode()) |
|
24
|
|
|
// admins configuration |
|
25
|
|
|
->append($this->getAdminsConfigurationNode()) |
|
26
|
|
|
// menus configurations |
|
27
|
|
|
->append($this->getMenuConfiguration()) |
|
28
|
|
|
->end() |
|
29
|
|
|
->end(); |
|
30
|
|
|
|
|
31
|
|
|
return $treeBuilder; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @return ArrayNodeDefinition|NodeDefinition |
|
36
|
|
|
*/ |
|
37
|
|
|
protected function getAdminsConfigurationNode() |
|
38
|
|
|
{ |
|
39
|
|
|
$builder = new TreeBuilder(); |
|
40
|
|
|
$node = $builder->root('admins'); |
|
41
|
|
|
|
|
42
|
|
|
$node |
|
43
|
|
|
// useAttributeAsKey() method will preserve keys when multiple configurations files are used and then avoid |
|
44
|
|
|
// admin not found by configuration override |
|
45
|
|
|
->useAttributeAsKey('name') |
|
46
|
|
|
->prototype('array') |
|
47
|
|
|
->children() |
|
48
|
|
|
->scalarNode('entity')->end() |
|
49
|
|
|
->scalarNode('data_provider')->end() |
|
50
|
|
|
->scalarNode('form')->end() |
|
51
|
|
|
->scalarNode('max_per_page')->end() |
|
52
|
|
|
->scalarNode('controller')->defaultValue('LAGAdminBundle:CRUD')->end() |
|
53
|
|
|
// actions configurations |
|
54
|
|
|
->variableNode('actions')->end() |
|
55
|
|
|
->end() |
|
56
|
|
|
->end(); |
|
57
|
|
|
|
|
58
|
|
|
return $node; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @return ArrayNodeDefinition|NodeDefinition |
|
63
|
|
|
*/ |
|
64
|
|
|
protected function getApplicationNode() |
|
65
|
|
|
{ |
|
66
|
|
|
$builder = new TreeBuilder(); |
|
67
|
|
|
$node = $builder->root('application'); |
|
68
|
|
|
|
|
69
|
|
|
$node |
|
70
|
|
|
->children() |
|
71
|
|
|
->scalarNode('title')->end() |
|
72
|
|
|
->scalarNode('description')->end() |
|
73
|
|
|
->scalarNode('base_template')->end() |
|
74
|
|
|
->scalarNode('date_format')->defaultValue('Y-m-d')->end() |
|
75
|
|
|
->scalarNode('bootstrap')->end() |
|
76
|
|
|
->scalarNode('max_per_page')->end() |
|
77
|
|
|
->scalarNode('routing_name_pattern')->end() |
|
78
|
|
|
->scalarNode('routing_url_pattern')->end() |
|
79
|
|
|
->booleanNode('translation')->end() |
|
80
|
|
|
->scalarNode('translation_pattern')->end() |
|
81
|
|
|
->scalarNode('block_template') |
|
82
|
|
|
->defaultValue('LAGAdminBundle:Form:fields.html.twig') |
|
83
|
|
|
->end() |
|
84
|
|
|
->arrayNode('fields_mapping') |
|
85
|
|
|
->prototype('scalar') |
|
86
|
|
|
->end() |
|
87
|
|
|
->end() |
|
88
|
|
|
->booleanNode('enable_extra_configuration')->end() |
|
89
|
|
|
->booleanNode('enable_security')->end() |
|
90
|
|
|
->booleanNode('enable_menus')->end() |
|
91
|
|
|
->booleanNode('enable_homepage')->end() |
|
92
|
|
|
->booleanNode('translation')->end() |
|
93
|
|
|
->variableNode('translation_pattern')->end() |
|
94
|
|
|
->scalarNode('title')->end() |
|
95
|
|
|
->scalarNode('description')->end() |
|
96
|
|
|
->scalarNode('locale')->end() |
|
97
|
|
|
->scalarNode('base_template')->end() |
|
98
|
|
|
->scalarNode('block_template')->end() |
|
99
|
|
|
->scalarNode('menu_template')->end() |
|
100
|
|
|
->scalarNode('homepage_template')->end() |
|
101
|
|
|
->scalarNode('homepage_route')->end() |
|
102
|
|
|
->scalarNode('routing_url_pattern')->end() |
|
103
|
|
|
->scalarNode('routing_name_pattern')->end() |
|
104
|
|
|
->scalarNode('bootstrap')->end() |
|
105
|
|
|
->scalarNode('date_format')->end() |
|
106
|
|
|
->scalarNode('pager')->end() |
|
107
|
|
|
->scalarNode('string_length')->end() |
|
108
|
|
|
->scalarNode('string_length_truncate')->end() |
|
109
|
|
|
->scalarNode('max_per_page')->end() |
|
110
|
|
|
->scalarNode('admin_class')->end() |
|
111
|
|
|
->scalarNode('action_class')->end() |
|
112
|
|
|
->scalarNode('permissions')->end() |
|
113
|
|
|
->scalarNode('page_parameter')->end() |
|
114
|
|
|
->end() |
|
115
|
|
|
->end(); |
|
116
|
|
|
|
|
117
|
|
|
return $node; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* @return ArrayNodeDefinition|NodeDefinition |
|
122
|
|
|
*/ |
|
123
|
|
|
protected function getMenuConfiguration() |
|
124
|
|
|
{ |
|
125
|
|
|
$builder = new TreeBuilder(); |
|
126
|
|
|
$node = $builder->root('menus'); |
|
127
|
|
|
|
|
128
|
|
|
$node |
|
129
|
|
|
->prototype('variable') |
|
130
|
|
|
->end() |
|
131
|
|
|
->end(); |
|
132
|
|
|
|
|
133
|
|
|
return $node; |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
|