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