Completed
Push — master ( b1c6ca...52cd2c )
by Kamil
77:57 queued 60:05
created

Configuration   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 35
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 32 1
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
declare(strict_types=1);
13
14
namespace Sylius\Bundle\UiBundle\DependencyInjection;
15
16
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
17
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
18
use Symfony\Component\Config\Definition\ConfigurationInterface;
19
20
final class Configuration implements ConfigurationInterface
21
{
22
    public function getConfigTreeBuilder(): TreeBuilder
23
    {
24
        $treeBuilder = new TreeBuilder('sylius_ui');
25
        /** @var ArrayNodeDefinition $rootNode */
26
        $rootNode = $treeBuilder->getRootNode();
27
28
        $rootNode
29
            ->fixXmlConfig('event')
30
            ->children()
31
                ->arrayNode('events')
32
                    ->useAttributeAsKey('event_name')
33
                    ->arrayPrototype()
34
                        ->fixXmlConfig('block')
35
                        ->children()
36
                            ->arrayNode('blocks')
37
                                ->defaultValue([])
38
                                ->useAttributeAsKey('block_name')
39
                                ->arrayPrototype()
40
                                    ->canBeDisabled()
41
                                    ->beforeNormalization()
42
                                        ->ifString()
43
                                        ->then(static function (string $template): array {
44
                                            return ['template' => $template];
45
                                        })
46
                                    ->end()
47
                                    ->children()
48
                                        ->scalarNode('template')->isRequired()->cannotBeEmpty()->end()
49
                                        ->integerNode('priority')->defaultValue(0)->end()
50
        ;
51
52
        return $treeBuilder;
53
    }
54
}
55