|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Odiseo\SyliusReportPlugin\DependencyInjection; |
|
6
|
|
|
|
|
7
|
|
|
use Odiseo\SyliusReportPlugin\Controller\ReportController; |
|
8
|
|
|
use Odiseo\SyliusReportPlugin\Repository\ReportRepository; |
|
9
|
|
|
use Odiseo\SyliusReportPlugin\Form\Type\ReportType; |
|
10
|
|
|
use Odiseo\SyliusReportPlugin\Model\Report; |
|
11
|
|
|
use Odiseo\SyliusReportPlugin\Model\ReportInterface; |
|
12
|
|
|
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle; |
|
13
|
|
|
use Sylius\Component\Resource\Factory\Factory; |
|
14
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
|
15
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
16
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* This class contains the configuration information for the bundle. |
|
20
|
|
|
* |
|
21
|
|
|
* This information is solely responsible for how the different configuration |
|
22
|
|
|
* sections are normalized, and merged. |
|
23
|
|
|
* |
|
24
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
|
25
|
|
|
* @author Diego D'amico <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
final class Configuration implements ConfigurationInterface |
|
28
|
|
|
{ |
|
29
|
|
|
public function getConfigTreeBuilder(): TreeBuilder |
|
30
|
|
|
{ |
|
31
|
|
|
$treeBuilder = new TreeBuilder('odiseo_sylius_report_plugin'); |
|
32
|
|
|
$rootNode = $treeBuilder->getRootNode(); |
|
33
|
|
|
|
|
34
|
|
|
$rootNode |
|
35
|
|
|
->addDefaultsIfNotSet() |
|
|
|
|
|
|
36
|
|
|
->children() |
|
37
|
|
|
->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end() |
|
38
|
|
|
->scalarNode('renderer_configuration_template')->defaultValue('@OdiseoSyliusReportPlugin/_rendererConfiguration.html.twig')->end() |
|
39
|
|
|
->scalarNode('data_fetcher_configuration_template')->defaultValue('@OdiseoSyliusReportPlugin/_dataFetcherConfiguration.html.twig')->end() |
|
40
|
|
|
->end() |
|
41
|
|
|
; |
|
42
|
|
|
|
|
43
|
|
|
$this->addResourcesSection($rootNode); |
|
44
|
|
|
|
|
45
|
|
|
return $treeBuilder; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
private function addResourcesSection(ArrayNodeDefinition $node): void |
|
49
|
|
|
{ |
|
50
|
|
|
$node |
|
51
|
|
|
->children() |
|
52
|
|
|
->arrayNode('resources') |
|
53
|
|
|
->addDefaultsIfNotSet() |
|
54
|
|
|
->children() |
|
55
|
|
|
->arrayNode('report') |
|
56
|
|
|
->addDefaultsIfNotSet() |
|
57
|
|
|
->children() |
|
58
|
|
|
->variableNode('options')->end() |
|
59
|
|
|
->arrayNode('classes') |
|
|
|
|
|
|
60
|
|
|
->addDefaultsIfNotSet() |
|
61
|
|
|
->children() |
|
62
|
|
|
->scalarNode('model')->defaultValue(Report::class)->cannotBeEmpty()->end() |
|
63
|
|
|
->scalarNode('interface')->defaultValue(ReportInterface::class)->cannotBeEmpty()->end() |
|
64
|
|
|
->scalarNode('controller')->defaultValue(ReportController::class)->cannotBeEmpty()->end() |
|
65
|
|
|
->scalarNode('repository')->defaultValue(ReportRepository::class)->cannotBeEmpty()->end() |
|
66
|
|
|
->scalarNode('factory')->defaultValue(Factory::class)->end() |
|
67
|
|
|
->scalarNode('form')->defaultValue(ReportType::class)->cannotBeEmpty()->end() |
|
68
|
|
|
->end() |
|
69
|
|
|
->end() |
|
70
|
|
|
->end() |
|
71
|
|
|
->end() |
|
72
|
|
|
->end() |
|
73
|
|
|
->end() |
|
74
|
|
|
->end() |
|
75
|
|
|
; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|