Completed
Push — sf5-deprecated-events ( 340c69...185721 )
by Kamil
06:54
created

Configuration   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 53 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\ShopBundle\DependencyInjection;
15
16
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
17
use Symfony\Component\Config\Definition\ConfigurationInterface;
18
19
final class Configuration implements ConfigurationInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function getConfigTreeBuilder(): TreeBuilder
25
    {
26
        $treeBuilder = new TreeBuilder('sylius_shop');
27
        $rootNode = $treeBuilder->getRootNode();
28
29
        $rootNode
30
            ->children()
31
                ->enumNode('locale_switcher')->values(['storage', 'url'])->defaultValue('url')->end()
32
                ->scalarNode('firewall_context_name')->defaultValue('shop')->end()
33
                ->arrayNode('checkout_resolver')
34
                    ->addDefaultsIfNotSet()
35
                    ->children()
36
                        ->booleanNode('enabled')
37
                            ->defaultTrue()
38
                        ->end()
39
                        ->scalarNode('pattern')
40
                            ->defaultValue('/checkout/.+')
41
                            ->validate()
42
                            ->ifTrue(
43
                                /** @param mixed $pattern */
44
                                function ($pattern) {
45
                                    return !is_string($pattern);
46
                                }
47
                            )
48
                                ->thenInvalid('Invalid pattern "%s"')
49
                            ->end()
50
                        ->end()
51
                        ->arrayNode('route_map')
52
                            ->useAttributeAsKey('name')
53
                            ->arrayPrototype()
54
                                ->children()
55
                                    ->scalarNode('route')
56
                                        ->cannotBeEmpty()
57
                                        ->isRequired()
58
                                    ->end()
59
                                ->end()
60
                            ->end()
61
                        ->end()
62
                    ->end()
63
                ->end()
64
                ->arrayNode('product_grid')
65
                    ->addDefaultsIfNotSet()
66
                    ->children()
67
                        ->booleanNode('include_all_descendants')
68
                            ->defaultFalse()
69
                        ->end()
70
                    ->end()
71
                ->end()
72
            ->end()
73
        ;
74
75
        return $treeBuilder;
76
    }
77
}
78