1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Sylius\Bundle\AttributeBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Sylius\Bundle\AttributeBundle\Controller\ProductAttributeController; |
15
|
|
|
use Sylius\Bundle\AttributeBundle\Form\Type\AttributeTranslationType; |
16
|
|
|
use Sylius\Bundle\AttributeBundle\Form\Type\AttributeType; |
17
|
|
|
use Sylius\Bundle\AttributeBundle\Form\Type\AttributeValueType; |
18
|
|
|
use Sylius\Bundle\ResourceBundle\Controller\ResourceController; |
19
|
|
|
use Sylius\Bundle\ResourceBundle\Form\Type\ResourceChoiceType; |
20
|
|
|
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle; |
21
|
|
|
use Sylius\Component\Attribute\Model\Attribute; |
22
|
|
|
use Sylius\Component\Attribute\Model\AttributeInterface; |
23
|
|
|
use Sylius\Component\Attribute\Model\AttributeTranslation; |
24
|
|
|
use Sylius\Component\Attribute\Model\AttributeTranslationInterface; |
25
|
|
|
use Sylius\Component\Resource\Factory\Factory; |
26
|
|
|
use Sylius\Component\Resource\Factory\TranslatableFactory; |
27
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
28
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
29
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
33
|
|
|
*/ |
34
|
|
|
final class Configuration implements ConfigurationInterface |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* {@inheritdoc} |
38
|
|
|
*/ |
39
|
|
|
public function getConfigTreeBuilder() |
40
|
|
|
{ |
41
|
|
|
$treeBuilder = new TreeBuilder(); |
42
|
|
|
$rootNode = $treeBuilder->root('sylius_attribute'); |
43
|
|
|
|
44
|
|
|
$rootNode |
45
|
|
|
->addDefaultsIfNotSet() |
46
|
|
|
->children() |
47
|
|
|
->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end() |
48
|
|
|
->end() |
49
|
|
|
; |
50
|
|
|
|
51
|
|
|
$this->addResourcesSection($rootNode); |
52
|
|
|
|
53
|
|
|
return $treeBuilder; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param ArrayNodeDefinition $node |
58
|
|
|
*/ |
59
|
|
|
private function addResourcesSection(ArrayNodeDefinition $node) |
60
|
|
|
{ |
61
|
|
|
$node |
62
|
|
|
->children() |
63
|
|
|
->arrayNode('resources') |
64
|
|
|
->useAttributeAsKey('name') |
65
|
|
|
->prototype('array') |
66
|
|
|
->children() |
67
|
|
|
->scalarNode('subject')->isRequired()->end() |
68
|
|
|
->arrayNode('attribute') |
69
|
|
|
->addDefaultsIfNotSet() |
70
|
|
|
->children() |
71
|
|
|
->variableNode('options')->end() |
72
|
|
|
->arrayNode('classes') |
73
|
|
|
->addDefaultsIfNotSet() |
74
|
|
|
->children() |
75
|
|
|
->scalarNode('model')->defaultValue(Attribute::class)->cannotBeEmpty()->end() |
76
|
|
|
->scalarNode('interface')->defaultValue(AttributeInterface::class)->cannotBeEmpty()->end() |
77
|
|
|
->scalarNode('controller')->cannotBeEmpty()->end() |
78
|
|
|
->scalarNode('repository')->cannotBeEmpty()->end() |
79
|
|
|
->scalarNode('factory')->defaultValue(TranslatableFactory::class)->end() |
80
|
|
|
->scalarNode('form')->cannotBeEmpty()->end() |
81
|
|
|
->end() |
82
|
|
|
->end() |
83
|
|
|
->arrayNode('translation') |
84
|
|
|
->addDefaultsIfNotSet() |
85
|
|
|
->children() |
86
|
|
|
->variableNode('options')->end() |
87
|
|
|
->arrayNode('classes') |
88
|
|
|
->addDefaultsIfNotSet() |
89
|
|
|
->children() |
90
|
|
|
->scalarNode('model')->defaultValue(AttributeTranslation::class)->cannotBeEmpty()->end() |
91
|
|
|
->scalarNode('interface')->defaultValue(AttributeTranslationInterface::class)->cannotBeEmpty()->end() |
92
|
|
|
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() |
93
|
|
|
->scalarNode('repository')->cannotBeEmpty()->end() |
94
|
|
|
->scalarNode('factory')->defaultValue(Factory::class)->end() |
95
|
|
|
->scalarNode('form')->cannotBeEmpty()->end() |
96
|
|
|
->end() |
97
|
|
|
->end() |
98
|
|
|
->end() |
99
|
|
|
->end() |
100
|
|
|
->end() |
101
|
|
|
->end() |
102
|
|
|
->arrayNode('attribute_value') |
103
|
|
|
->isRequired() |
104
|
|
|
->addDefaultsIfNotSet() |
105
|
|
|
->children() |
106
|
|
|
->variableNode('options')->end() |
107
|
|
|
->arrayNode('classes') |
108
|
|
|
->addDefaultsIfNotSet() |
109
|
|
|
->children() |
110
|
|
|
->scalarNode('model')->isRequired()->cannotBeEmpty()->end() |
111
|
|
|
->scalarNode('interface')->isRequired()->cannotBeEmpty()->end() |
112
|
|
|
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() |
113
|
|
|
->scalarNode('repository')->cannotBeEmpty()->end() |
114
|
|
|
->scalarNode('factory')->defaultValue(Factory::class)->end() |
115
|
|
|
->scalarNode('form')->cannotBeEmpty()->end() |
116
|
|
|
->end() |
117
|
|
|
->end() |
118
|
|
|
->end() |
119
|
|
|
->end() |
120
|
|
|
->end() |
121
|
|
|
->end() |
122
|
|
|
->end() |
123
|
|
|
->end() |
124
|
|
|
; |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|