Passed
Push — main ( 68245a...b2eda1 )
by Axel
05:57
created

Configuration   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 33
dl 0
loc 40
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 38 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Zikula package.
7
 *
8
 * Copyright Zikula - https://ziku.la/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Zikula\UsersBundle\DependencyInjection;
15
16
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
17
use Symfony\Component\Config\Definition\ConfigurationInterface;
18
use Zikula\UsersBundle\UsersConstant;
19
20
class Configuration implements ConfigurationInterface
21
{
22
    public function getConfigTreeBuilder(): TreeBuilder
23
    {
24
        $treeBuilder = new TreeBuilder('zikula_users');
25
26
        $treeBuilder->getRootNode()
27
            ->children()
28
                ->booleanNode('allow_self_deletion')
29
                    ->info('Allow users to delete themselves.')
30
                    ->defaultFalse()
31
                ->end()
32
                ->arrayNode('registration')
33
                    ->info('Registration settings.')
34
                    ->addDefaultsIfNotSet()
35
                    ->children()
36
                        ->booleanNode('enabled')
37
                            ->info('Allow new user account registrations.')
38
                            ->defaultTrue()
39
                        ->end()
40
                        ->scalarNode('disabled_reason')
41
                            ->info('Statement displayed if registration disabled.')
42
                            ->defaultValue('Sorry! New user registration is currently disabled.')
43
                        ->end()
44
                        ->scalarNode('admin_notification_mail')
45
                            ->info('E-mail address to notify of registrations (leave blank for no notifications).')
46
                            ->defaultNull()
47
                            ->validate()
48
                                ->ifTrue(static function ($v) {
49
                                    return null !== $v && !filter_var($v, FILTER_VALIDATE_EMAIL);
50
                                })
51
                                ->thenInvalid('Please enter a valid mail address.')
52
                            ->end()
53
                        ->end()
54
                    ->end()
55
                ->end()
56
            ->end()
57
        ;
58
59
        return $treeBuilder;
60
    }
61
}
62