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\TaxationBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Sylius\Bundle\ResourceBundle\Controller\ResourceController; |
15
|
|
|
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle; |
16
|
|
|
use Sylius\Bundle\TaxationBundle\Form\Type\TaxCategoryType; |
17
|
|
|
use Sylius\Bundle\TaxationBundle\Form\Type\TaxRateType; |
18
|
|
|
use Sylius\Component\Resource\Factory\Factory; |
19
|
|
|
use Sylius\Component\Taxation\Model\TaxCategory; |
20
|
|
|
use Sylius\Component\Taxation\Model\TaxCategoryInterface; |
21
|
|
|
use Sylius\Component\Taxation\Model\TaxRate; |
22
|
|
|
use Sylius\Component\Taxation\Model\TaxRateInterface; |
23
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
24
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
25
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
29
|
|
|
*/ |
30
|
|
|
final class Configuration implements ConfigurationInterface |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* {@inheritdoc} |
34
|
|
|
*/ |
35
|
|
|
public function getConfigTreeBuilder() |
36
|
|
|
{ |
37
|
|
|
$treeBuilder = new TreeBuilder(); |
38
|
|
|
$rootNode = $treeBuilder->root('sylius_taxation'); |
39
|
|
|
|
40
|
|
|
$rootNode |
41
|
|
|
->addDefaultsIfNotSet() |
42
|
|
|
->children() |
43
|
|
|
->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end() |
44
|
|
|
->end() |
45
|
|
|
; |
46
|
|
|
|
47
|
|
|
$this->addClassesSection($rootNode); |
48
|
|
|
|
49
|
|
|
return $treeBuilder; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param ArrayNodeDefinition $node |
54
|
|
|
*/ |
55
|
|
|
private function addClassesSection(ArrayNodeDefinition $node) |
56
|
|
|
{ |
57
|
|
|
$node |
58
|
|
|
->children() |
59
|
|
|
->arrayNode('resources') |
60
|
|
|
->addDefaultsIfNotSet() |
61
|
|
|
->children() |
62
|
|
|
->arrayNode('tax_category') |
63
|
|
|
->addDefaultsIfNotSet() |
64
|
|
|
->children() |
65
|
|
|
->variableNode('options')->end() |
66
|
|
|
->arrayNode('classes') |
67
|
|
|
->addDefaultsIfNotSet() |
68
|
|
|
->children() |
69
|
|
|
->scalarNode('model')->defaultValue(TaxCategory::class)->cannotBeEmpty()->end() |
70
|
|
|
->scalarNode('interface')->defaultValue(TaxCategoryInterface::class)->cannotBeEmpty()->end() |
71
|
|
|
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() |
72
|
|
|
->scalarNode('repository')->cannotBeEmpty()->end() |
73
|
|
|
->scalarNode('factory')->defaultValue(Factory::class)->end() |
74
|
|
|
->scalarNode('form')->defaultValue(TaxCategoryType::class)->cannotBeEmpty()->end() |
75
|
|
|
->end() |
76
|
|
|
->end() |
77
|
|
|
->end() |
78
|
|
|
->end() |
79
|
|
|
->arrayNode('tax_rate') |
80
|
|
|
->addDefaultsIfNotSet() |
81
|
|
|
->children() |
82
|
|
|
->variableNode('options')->end() |
83
|
|
|
->arrayNode('classes') |
84
|
|
|
->addDefaultsIfNotSet() |
85
|
|
|
->children() |
86
|
|
|
->scalarNode('model')->defaultValue(TaxRate::class)->cannotBeEmpty()->end() |
87
|
|
|
->scalarNode('interface')->defaultValue(TaxRateInterface::class)->cannotBeEmpty()->end() |
88
|
|
|
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() |
89
|
|
|
->scalarNode('repository')->cannotBeEmpty()->end() |
90
|
|
|
->scalarNode('factory')->defaultValue(Factory::class)->end() |
91
|
|
|
->scalarNode('form')->defaultValue(TaxRateType::class)->cannotBeEmpty()->end() |
92
|
|
|
->end() |
93
|
|
|
->end() |
94
|
|
|
->end() |
95
|
|
|
->end() |
96
|
|
|
->end() |
97
|
|
|
->end() |
98
|
|
|
->end() |
99
|
|
|
; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|