1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** @noinspection PhpUnusedLocalVariableInspection */ |
4
|
|
|
|
5
|
|
|
declare(strict_types=1); |
6
|
|
|
|
7
|
|
|
namespace Loevgaard\SyliusBrandPlugin\DependencyInjection; |
8
|
|
|
|
9
|
|
|
use Loevgaard\SyliusBrandPlugin\Doctrine\ORM\BrandImageRepository; |
10
|
|
|
use Loevgaard\SyliusBrandPlugin\Doctrine\ORM\BrandRepository; |
11
|
|
|
use Loevgaard\SyliusBrandPlugin\Form\Type\BrandImageType; |
12
|
|
|
use Loevgaard\SyliusBrandPlugin\Form\Type\BrandType; |
13
|
|
|
use Loevgaard\SyliusBrandPlugin\Model\Brand; |
14
|
|
|
use Loevgaard\SyliusBrandPlugin\Model\BrandImage; |
15
|
|
|
use Loevgaard\SyliusBrandPlugin\Model\BrandImageInterface; |
16
|
|
|
use Loevgaard\SyliusBrandPlugin\Model\BrandInterface; |
17
|
|
|
use Sylius\Bundle\ResourceBundle\Controller\ResourceController; |
18
|
|
|
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle; |
19
|
|
|
use Sylius\Component\Resource\Factory\Factory; |
20
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
21
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
22
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
23
|
|
|
|
24
|
|
|
final class Configuration implements ConfigurationInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
*/ |
29
|
|
|
public function getConfigTreeBuilder(): TreeBuilder |
30
|
|
|
{ |
31
|
|
|
if (method_exists(TreeBuilder::class, 'getRootNode')) { |
32
|
|
|
$treeBuilder = new TreeBuilder('loevgaard_sylius_brand'); |
33
|
|
|
$rootNode = $treeBuilder->getRootNode(); |
34
|
|
|
} else { |
35
|
|
|
// BC layer for symfony/config 4.1 and older |
36
|
|
|
$treeBuilder = new TreeBuilder(); |
37
|
|
|
$rootNode = $treeBuilder->root('loevgaard_sylius_brand'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
$rootNode |
41
|
|
|
->addDefaultsIfNotSet() |
|
|
|
|
42
|
|
|
->children() |
43
|
|
|
->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end() |
44
|
|
|
->end() |
45
|
|
|
; |
46
|
|
|
|
47
|
|
|
$this->addResourcesSection($rootNode); |
48
|
|
|
|
49
|
|
|
return $treeBuilder; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param ArrayNodeDefinition $node |
54
|
|
|
*/ |
55
|
|
|
private function addResourcesSection(ArrayNodeDefinition $node): void |
56
|
|
|
{ |
57
|
|
|
$node |
58
|
|
|
->children() |
59
|
|
|
->arrayNode('resources') |
60
|
|
|
->addDefaultsIfNotSet() |
61
|
|
|
->children() |
62
|
|
|
->arrayNode('brand') |
63
|
|
|
->addDefaultsIfNotSet() |
64
|
|
|
->children() |
65
|
|
|
->variableNode('options')->end() |
66
|
|
|
->arrayNode('classes') |
|
|
|
|
67
|
|
|
->addDefaultsIfNotSet() |
68
|
|
|
->children() |
69
|
|
|
->scalarNode('model')->defaultValue(Brand::class)->cannotBeEmpty()->end() |
70
|
|
|
->scalarNode('interface')->defaultValue(BrandInterface::class)->cannotBeEmpty()->end() |
71
|
|
|
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() |
72
|
|
|
->scalarNode('repository')->defaultValue(BrandRepository::class)->cannotBeEmpty()->end() |
73
|
|
|
->scalarNode('factory')->defaultValue(Factory::class)->end() |
74
|
|
|
->scalarNode('form')->defaultValue(BrandType::class)->cannotBeEmpty()->end() |
75
|
|
|
->end() |
76
|
|
|
->end() |
77
|
|
|
->end() |
78
|
|
|
->end() |
79
|
|
|
->arrayNode('brand_image') |
80
|
|
|
->addDefaultsIfNotSet() |
81
|
|
|
->children() |
82
|
|
|
->variableNode('options')->end() |
83
|
|
|
->arrayNode('classes') |
84
|
|
|
->addDefaultsIfNotSet() |
85
|
|
|
->children() |
86
|
|
|
->scalarNode('model')->defaultValue(BrandImage::class)->cannotBeEmpty()->end() |
87
|
|
|
->scalarNode('interface')->defaultValue(BrandImageInterface::class)->cannotBeEmpty()->end() |
88
|
|
|
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() |
89
|
|
|
->scalarNode('repository')->defaultValue(BrandImageRepository::class)->cannotBeEmpty()->end() |
90
|
|
|
->scalarNode('factory')->defaultValue(Factory::class)->end() |
91
|
|
|
->scalarNode('form')->defaultValue(BrandImageType::class)->cannotBeEmpty()->end() |
92
|
|
|
->end() |
93
|
|
|
->end() |
94
|
|
|
->end() |
95
|
|
|
->end() |
96
|
|
|
->end() |
97
|
|
|
->end() |
98
|
|
|
->end() |
99
|
|
|
; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|