|
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
|
|
|
->append($this->getMenuConfiguration()) |
|
25
|
|
|
->end() |
|
26
|
|
|
->end(); |
|
27
|
|
|
|
|
28
|
|
|
return $treeBuilder; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @return ArrayNodeDefinition|NodeDefinition |
|
33
|
|
|
*/ |
|
34
|
|
|
public function getAdminsConfigurationNode() |
|
35
|
|
|
{ |
|
36
|
|
|
$builder = new TreeBuilder(); |
|
37
|
|
|
$node = $builder->root('admins'); |
|
38
|
|
|
|
|
39
|
|
|
$node |
|
40
|
|
|
->prototype('array') |
|
41
|
|
|
->children() |
|
42
|
|
|
->scalarNode('entity')->end() |
|
43
|
|
|
->scalarNode('data_provider')->end() |
|
44
|
|
|
->scalarNode('form')->end() |
|
45
|
|
|
->scalarNode('max_per_page')->end() |
|
46
|
|
|
->scalarNode('controller')->defaultValue('LAGAdminBundle:CRUD')->end() |
|
47
|
|
|
// actions configurations |
|
48
|
|
|
->variableNode('actions')->end() |
|
49
|
|
|
->end() |
|
50
|
|
|
->end(); |
|
51
|
|
|
|
|
52
|
|
|
return $node; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return ArrayNodeDefinition|NodeDefinition |
|
57
|
|
|
*/ |
|
58
|
|
|
public function getApplicationNode() |
|
59
|
|
|
{ |
|
60
|
|
|
$builder = new TreeBuilder(); |
|
61
|
|
|
$node = $builder->root('application'); |
|
62
|
|
|
|
|
63
|
|
|
$node |
|
64
|
|
|
->children() |
|
65
|
|
|
->scalarNode('title')->end() |
|
66
|
|
|
->scalarNode('description')->end() |
|
67
|
|
|
->scalarNode('base_template')->end() |
|
68
|
|
|
->scalarNode('date_format')->defaultValue('Y-m-d')->end() |
|
69
|
|
|
->scalarNode('bootstrap')->end() |
|
70
|
|
|
->scalarNode('max_per_page')->end() |
|
71
|
|
|
->arrayNode('routing') |
|
72
|
|
|
->children() |
|
73
|
|
|
->scalarNode('name_pattern')->end() |
|
74
|
|
|
->scalarNode('url_pattern')->end() |
|
75
|
|
|
->end() |
|
76
|
|
|
->end() |
|
77
|
|
|
->arrayNode('translation') |
|
78
|
|
|
->canBeDisabled() |
|
79
|
|
|
->children() |
|
80
|
|
|
->scalarNode('pattern')->end() |
|
81
|
|
|
->end() |
|
82
|
|
|
->end() |
|
83
|
|
|
->scalarNode('block_template') |
|
84
|
|
|
->defaultValue('LAGAdminBundle:Form:fields.html.twig') |
|
85
|
|
|
->end() |
|
86
|
|
|
->arrayNode('fields_mapping') |
|
87
|
|
|
->prototype('scalar') |
|
88
|
|
|
->end() |
|
89
|
|
|
->end() |
|
90
|
|
|
->variableNode('menus')->end() |
|
91
|
|
|
->end() |
|
92
|
|
|
->end(); |
|
93
|
|
|
|
|
94
|
|
|
return $node; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function getMenuConfiguration() |
|
98
|
|
|
{ |
|
99
|
|
|
$builder = new TreeBuilder(); |
|
100
|
|
|
$node = $builder->root('menus'); |
|
101
|
|
|
|
|
102
|
|
|
$node |
|
103
|
|
|
->prototype('variable') |
|
104
|
|
|
->end() |
|
105
|
|
|
->end(); |
|
106
|
|
|
|
|
107
|
|
|
return $node; |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|