|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Lakion\SyliusCmsBundle\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use Lakion\SyliusCmsBundle\Document\Route; |
|
6
|
|
|
use Lakion\SyliusCmsBundle\Document\StaticContent; |
|
7
|
|
|
use Lakion\SyliusCmsBundle\Form\Type\RouteType; |
|
8
|
|
|
use Lakion\SyliusCmsBundle\Form\Type\StaticContentType; |
|
9
|
|
|
use Lakion\SyliusCmsBundle\Repository\StaticContentRepository; |
|
10
|
|
|
use Sylius\Bundle\ResourceBundle\Controller\ResourceController; |
|
11
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
|
12
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
13
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
14
|
|
|
|
|
15
|
|
|
final class Configuration implements ConfigurationInterface |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* {@inheritdoc} |
|
19
|
|
|
*/ |
|
20
|
|
|
public function getConfigTreeBuilder() |
|
21
|
|
|
{ |
|
22
|
|
|
$treeBuilder = new TreeBuilder(); |
|
23
|
|
|
$rootNode = $treeBuilder->root('lakion_sylius_cms'); |
|
24
|
|
|
|
|
25
|
|
|
$this->addResourcesSection($rootNode); |
|
26
|
|
|
|
|
27
|
|
|
return $treeBuilder; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param ArrayNodeDefinition $node |
|
32
|
|
|
*/ |
|
33
|
|
|
private function addResourcesSection(ArrayNodeDefinition $node) |
|
34
|
|
|
{ |
|
35
|
|
|
$node |
|
36
|
|
|
->children() |
|
37
|
|
|
->arrayNode('resources') |
|
38
|
|
|
->addDefaultsIfNotSet() |
|
39
|
|
|
->children() |
|
40
|
|
|
->arrayNode('route') |
|
41
|
|
|
->addDefaultsIfNotSet() |
|
42
|
|
|
->children() |
|
43
|
|
|
->variableNode('options')->end() |
|
44
|
|
|
->arrayNode('classes') |
|
45
|
|
|
->addDefaultsIfNotSet() |
|
46
|
|
|
->children() |
|
47
|
|
|
->scalarNode('model')->defaultValue(Route::class)->cannotBeEmpty()->cannotBeEmpty()->end() |
|
48
|
|
|
->scalarNode('controller')->defaultValue(ResourceController::class)->end() |
|
49
|
|
|
->scalarNode('repository')->cannotBeEmpty()->end() |
|
50
|
|
|
->scalarNode('form')->defaultValue(RouteType::class)->end() |
|
51
|
|
|
->end() |
|
52
|
|
|
->end() |
|
53
|
|
|
->end() |
|
54
|
|
|
->end() |
|
55
|
|
|
->arrayNode('static_content') |
|
56
|
|
|
->addDefaultsIfNotSet() |
|
57
|
|
|
->children() |
|
58
|
|
|
->variableNode('options')->end() |
|
59
|
|
|
->arrayNode('classes') |
|
60
|
|
|
->addDefaultsIfNotSet() |
|
61
|
|
|
->children() |
|
62
|
|
|
->scalarNode('model')->defaultValue(StaticContent::class)->cannotBeEmpty()->end() |
|
63
|
|
|
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() |
|
64
|
|
|
->scalarNode('repository')->defaultValue(StaticContentRepository::class)->cannotBeEmpty()->end() |
|
65
|
|
|
->scalarNode('form')->defaultValue(StaticContentType::class)->end() |
|
66
|
|
|
->end() |
|
67
|
|
|
->end() |
|
68
|
|
|
->end() |
|
69
|
|
|
->end() |
|
70
|
|
|
->end() |
|
71
|
|
|
->end() |
|
72
|
|
|
->end() |
|
73
|
|
|
; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|