Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 23
c 2
b 1
f 0
dl 0
loc 28
rs 9.552
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Loevgaard\SyliusBarcodePlugin\DependencyInjection;
6
7
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
8
use Symfony\Component\Config\Definition\ConfigurationInterface;
9
10
final class Configuration implements ConfigurationInterface
11
{
12
    public function getConfigTreeBuilder(): TreeBuilder
13
    {
14
        $treeBuilder = new TreeBuilder('loevgaard_sylius_barcode');
15
        $rootNode = $treeBuilder->getRootNode();
16
17
        $rootNode
18
            ->children()
19
                ->arrayNode('form')
20
                    ->addDefaultsIfNotSet()
21
                    ->children()
22
                        ->booleanNode('require')
23
                            ->defaultFalse()
24
                            ->info('If true the barcode field will be required in the product forms (both product and variant)')
25
                        ->end()
26
                        ->booleanNode('require_valid')
27
                            ->defaultFalse()
28
                            ->info('If true the barcode field will be validated when entered in the product forms (both product and variant)')
29
                        ->end()
30
                        ->booleanNode('require_unique')
31
                            ->defaultTrue()
32
                            ->info('If true the barcode unique constraint will be added to the field')
33
                        ->end()
34
                    ->end()
35
                ->end()
36
            ->end()
37
        ;
38
39
        return $treeBuilder;
40
    }
41
}
42