|
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
|
|
|
public function getConfigTreeBuilder() |
|
13
|
|
|
{ |
|
14
|
|
|
$treeBuilder = new TreeBuilder(); |
|
15
|
|
|
$rootNode = $treeBuilder->root('lag_admin'); |
|
16
|
|
|
|
|
17
|
|
|
$rootNode |
|
18
|
|
|
->children() |
|
19
|
|
|
// application configuration |
|
20
|
|
|
->append($this->getApplicationNode()) |
|
21
|
|
|
// admins configuration |
|
22
|
|
|
->append($this->getAdminsConfigurationNode()) |
|
23
|
|
|
// menus configurations |
|
24
|
|
|
->arrayNode('menus') |
|
25
|
|
|
->prototype('array') |
|
26
|
|
|
->children() |
|
27
|
|
|
->scalarNode('template')->defaultValue('LAGAdminBundle:Menu:main_menu.html.twig')->end() |
|
28
|
|
|
->arrayNode('main_item') |
|
29
|
|
|
->children() |
|
30
|
|
|
->scalarNode('route')->end() |
|
31
|
|
|
->scalarNode('title')->end() |
|
32
|
|
|
->end() |
|
33
|
|
|
->end() |
|
34
|
|
|
->arrayNode('items') |
|
35
|
|
|
->prototype('array') |
|
36
|
|
|
->children() |
|
37
|
|
|
->scalarNode('admin')->end() |
|
38
|
|
|
->scalarNode('action')->end() |
|
39
|
|
|
->scalarNode('title')->end() |
|
40
|
|
|
->arrayNode('permissions') |
|
41
|
|
|
->defaultValue(['ROLE_USER']) |
|
42
|
|
|
->prototype('scalar') |
|
43
|
|
|
->end() |
|
44
|
|
|
->end() |
|
45
|
|
|
->end() |
|
46
|
|
|
->end() |
|
47
|
|
|
->end() |
|
48
|
|
|
->end() |
|
49
|
|
|
->end() |
|
50
|
|
|
->end() |
|
51
|
|
|
->end() |
|
52
|
|
|
->end(); |
|
53
|
|
|
|
|
54
|
|
|
return $treeBuilder; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @return ArrayNodeDefinition|NodeDefinition |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getAdminsConfigurationNode() |
|
61
|
|
|
{ |
|
62
|
|
|
$builder = new TreeBuilder(); |
|
63
|
|
|
$node = $builder->root('admins'); |
|
64
|
|
|
|
|
65
|
|
|
$node |
|
66
|
|
|
->prototype('array') |
|
67
|
|
|
->children() |
|
68
|
|
|
->scalarNode('entity')->end() |
|
69
|
|
|
->scalarNode('data_provider')->end() |
|
70
|
|
|
->scalarNode('form')->end() |
|
71
|
|
|
->scalarNode('max_per_page')->end() |
|
72
|
|
|
->scalarNode('controller')->defaultValue('LAGAdminBundle:CRUD')->end() |
|
73
|
|
|
// actions configurations |
|
74
|
|
|
->arrayNode('actions') |
|
75
|
|
|
->useAttributeAsKey('name') |
|
76
|
|
|
->prototype('array') |
|
77
|
|
|
->children() |
|
78
|
|
|
->scalarNode('title')->end() |
|
79
|
|
|
->arrayNode('permissions') |
|
80
|
|
|
->defaultValue(['ROLE_USER']) |
|
81
|
|
|
->prototype('scalar')->end() |
|
82
|
|
|
->end() |
|
83
|
|
|
->arrayNode('export') |
|
84
|
|
|
->prototype('scalar')->end() |
|
85
|
|
|
->end() |
|
86
|
|
|
->arrayNode('order') |
|
87
|
|
|
->prototype('array') |
|
88
|
|
|
->children() |
|
89
|
|
|
->scalarNode('field')->end() |
|
90
|
|
|
->scalarNode('order')->end() |
|
91
|
|
|
->end() |
|
92
|
|
|
->end() |
|
93
|
|
|
->end() |
|
94
|
|
|
->arrayNode('fields') |
|
95
|
|
|
->prototype('array') |
|
96
|
|
|
->children() |
|
97
|
|
|
->scalarNode('type')->end() |
|
98
|
|
|
->arrayNode('options') |
|
99
|
|
|
->prototype('variable')->end() |
|
100
|
|
|
->end() |
|
101
|
|
|
->end() |
|
102
|
|
|
->end() |
|
103
|
|
|
->end() |
|
104
|
|
|
->arrayNode('filters') |
|
105
|
|
|
->prototype('scalar')->end() |
|
106
|
|
|
->end() |
|
107
|
|
|
->end() |
|
108
|
|
|
->end() |
|
109
|
|
|
->end() |
|
110
|
|
|
->end() |
|
111
|
|
|
->end(); |
|
112
|
|
|
|
|
113
|
|
|
return $node; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @return ArrayNodeDefinition|NodeDefinition |
|
118
|
|
|
*/ |
|
119
|
|
|
public function getApplicationNode() |
|
120
|
|
|
{ |
|
121
|
|
|
$builder = new TreeBuilder(); |
|
122
|
|
|
$node = $builder->root('application'); |
|
123
|
|
|
|
|
124
|
|
|
$node |
|
125
|
|
|
->children() |
|
126
|
|
|
->scalarNode('title')->end() |
|
127
|
|
|
->scalarNode('description')->end() |
|
128
|
|
|
->scalarNode('base_template')->end() |
|
129
|
|
|
->scalarNode('date_format')->defaultValue('Y-m-d')->end() |
|
130
|
|
|
->scalarNode('bootstrap')->end() |
|
131
|
|
|
->scalarNode('max_per_page')->end() |
|
132
|
|
|
->arrayNode('routing') |
|
133
|
|
|
->children() |
|
134
|
|
|
->scalarNode('name_pattern')->end() |
|
135
|
|
|
->scalarNode('url_pattern')->end() |
|
136
|
|
|
->end() |
|
137
|
|
|
->end() |
|
138
|
|
|
->arrayNode('translation') |
|
139
|
|
|
->canBeDisabled() |
|
140
|
|
|
->children() |
|
141
|
|
|
->scalarNode('pattern')->end() |
|
142
|
|
|
->end() |
|
143
|
|
|
->end() |
|
144
|
|
|
->scalarNode('block_template') |
|
145
|
|
|
->defaultValue('LAGAdminBundle:Form:fields.html.twig') |
|
146
|
|
|
->end() |
|
147
|
|
|
->arrayNode('fields_mapping') |
|
148
|
|
|
->prototype('scalar') |
|
149
|
|
|
->end() |
|
150
|
|
|
->end() |
|
151
|
|
|
->end() |
|
152
|
|
|
->end(); |
|
153
|
|
|
|
|
154
|
|
|
return $node; |
|
155
|
|
|
} |
|
156
|
|
|
} |
|
157
|
|
|
|