-
-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathConfiguration.php
More file actions
99 lines (90 loc) · 4.55 KB
/
Configuration.php
File metadata and controls
99 lines (90 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
declare(strict_types=1);
namespace Setono\SyliusFeedPlugin\DependencyInjection;
use Setono\SyliusFeedPlugin\Doctrine\ORM\FeedRepository;
use Setono\SyliusFeedPlugin\Doctrine\ORM\ViolationRepository;
use Setono\SyliusFeedPlugin\Form\Type\FeedType;
use Setono\SyliusFeedPlugin\Model\Feed;
use Setono\SyliusFeedPlugin\Model\Violation;
use Sylius\Bundle\ResourceBundle\Controller\ResourceController;
use Sylius\Bundle\ResourceBundle\Form\Type\DefaultResourceType;
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
use Sylius\Component\Resource\Factory\Factory;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
final class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('setono_sylius_feed');
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();
$rootNode
->addDefaultsIfNotSet()
->children()
->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end()
->arrayNode('storage')
->addDefaultsIfNotSet()
->children()
->scalarNode('feed')
->info('A service id for the feed filesystem')
->cannotBeEmpty()
->defaultValue('setono_sylius_feed.storage.local.feed')
->end()
->scalarNode('feed_tmp')
->info('A service id for the temporary feed filesystem')
->cannotBeEmpty()
->defaultValue('setono_sylius_feed.storage.local.feed_tmp')
->end()
->end()
->end()
->end();
$this->addResourcesSection($rootNode);
return $treeBuilder;
}
private function addResourcesSection(ArrayNodeDefinition $node): void
{
$node
->children()
->arrayNode('resources')
->addDefaultsIfNotSet()
->children()
->arrayNode('feed')
->addDefaultsIfNotSet()
->children()
->variableNode('options')->end()
->arrayNode('classes')
->addDefaultsIfNotSet()
->children()
->scalarNode('model')->defaultValue(Feed::class)->cannotBeEmpty()->end()
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
->scalarNode('repository')->defaultValue(FeedRepository::class)->cannotBeEmpty()->end()
->scalarNode('factory')->defaultValue(Factory::class)->end()
->scalarNode('form')->defaultValue(FeedType::class)->cannotBeEmpty()->end()
->end()
->end()
->end()
->end()
->arrayNode('violation')
->addDefaultsIfNotSet()
->children()
->variableNode('options')->end()
->arrayNode('classes')
->addDefaultsIfNotSet()
->children()
->scalarNode('model')->defaultValue(Violation::class)->cannotBeEmpty()->end()
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
->scalarNode('repository')->defaultValue(ViolationRepository::class)->cannotBeEmpty()->end()
->scalarNode('factory')->defaultValue(Factory::class)->end()
->scalarNode('form')->defaultValue(DefaultResourceType::class)->cannotBeEmpty()->end()
->end()
->end()
->end()
->end()
->end()
->end()
->end()
;
}
}