Completed
Push — master ( cc9f19...85e40f )
by Pavel
11s
created

AclConfigDefinition   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 148
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 148
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 142 1
1
<?php
2
3
namespace App\Common\Config\Definition;
4
5
use Symfony\Component\Config\Definition\ConfigurationInterface;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
8
use App\Common\Acl;
9
10
/**
11
 * @inheritdoc
12
 */
13
class AclConfigDefinition implements ConfigurationInterface
14
{
15
    /**
16
     * @inheritdoc
17
     */
18
    public function getConfigTreeBuilder()
19
    {
20
        $treeBuilder = new TreeBuilder();
21
        $rootNode = $treeBuilder->root(null);
22
23
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
24
         * verify the following structure
25
         *   return [
26
         *       'definition' => ACLConfigDefinition::class,
27
         *
28
         *       'acl' => [
29
         *           'default_role' => 'guest',
30
         *
31
         *           'roles' => [
32
         *               // role => [multiple parents specification as array]
33
         *               'admin' => ['user'],
34
         *           ],
35
         *
36
         *           'resources' => [
37
         *              // resource => parent
38
         *           ],
39
         *
40
         *           // where we specify the guarding!
41
         *           'guards' => [
42
         *
43
         *              Acl::GUARD_TYPE_RESOURCE => [
44
         *
45
         *              ],
46
         *
47
         *              Acl::GUARD_TYPE_ROUTE => [
48
         *                   // resource, [roles as array], [privileges as array]
49
         *                   ['/api/token', ['guest'], [Acl::PRIVILEGE_POST]],
50
         *              ],
51
         *
52
         *              Acl::GUARD_TYPE_CALLABLE => [
53
         *                   // resource, [roles as array], [privileges as array]
54
         *                   ['App\Controller\CrudController',              ['user']],
55
         *              ],
56
         *           ],
57
         *       ],
58
         *   ];
59
         */
60
        $rootNode
61
            ->children()
62
                // 'definition' => ACLConfigDefinition::class,
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
63
                ->scalarNode('definition')
64
                    ->isRequired()
65
                    ->cannotBeEmpty()
66
                ->end()
67
68
                // 'acl' => []
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
69
                ->arrayNode('acl')
70
                    ->children()
71
72
                        // 'default_role' => 'guest',
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
73
                        ->scalarNode('default_role')
74
                            ->isRequired()
75
                            ->cannotBeEmpty()
76
                        ->end()
77
78
                        // 'roles' => [
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
79
                        //      'user'  => ['guest'],
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
80
                        //  ]
81
                        ->arrayNode('roles')
82
                            ->useAttributeAsKey('name')
83
                            ->prototype('array')
84
                                ->prototype('scalar')
85
                                ->end()
86
                            ->end()
87
                        ->end()
88
89
                        // 'resources' => []
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
90
                        ->arrayNode('resources')
91
                            ->useAttributeAsKey('name')
92
                            ->prototype('scalar')
93
                            ->end()
94
                        ->end()
95
96
                        // 'guards' => []
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
97
                        ->arrayNode('guards')
98
                            ->children()
99
                                ->arrayNode(Acl::GUARD_TYPE_RESOURCE)
100
                                    // ['user', ['admin']]
0 ignored issues
show
Unused Code Comprehensibility introduced by
78% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
101
                                    ->prototype('array')
102
                                        ->children()
103
                                            // 'user'
104
                                            ->scalarNode(0)
105
                                            ->end()
106
                                            // ['admin']
107
                                            ->arrayNode(1)
108
                                                ->prototype('scalar')
109
                                                ->end()
110
                                            ->end()
111
                                        ->end()
112
                                    ->end()
113
                                ->end()
114
115
                                ->arrayNode(Acl::GUARD_TYPE_ROUTE)
116
                                    // ['route', ['roles'], ['privilege1', 'privilege2']]
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
117
                                    ->prototype('array')
118
                                        ->children()
119
                                            // 'route'
120
                                            ->scalarNode(0)
121
                                            ->end()
122
                                            // ['roles']
123
                                            ->arrayNode(1)
124
                                                ->prototype('scalar')
125
                                                ->end()
126
                                            ->end()
127
                                            // ['privilege1', 'privilege2']
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
128
                                            ->arrayNode(2)
129
                                                ->prototype('scalar')
130
                                                ->end()
131
                                            ->end()
132
                                        ->end()
133
                                    ->end()
134
                                ->end()
135
136
                                ->arrayNode(Acl::GUARD_TYPE_CALLABLE)
137
                                    // ['callable', ['roles']]
0 ignored issues
show
Unused Code Comprehensibility introduced by
78% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
138
                                    ->prototype('array')
139
                                        ->children()
140
                                            // 'callable'
141
                                            ->scalarNode(0)
142
                                            ->end()
143
                                            // ['roles']
144
                                            ->arrayNode(1)
145
                                                ->prototype('scalar')
146
                                                ->end()
147
                                            ->end()
148
                                        ->end()
149
                                    ->end()
150
                                ->end()
151
                            ->end()
152
                        ->end()
153
                    ->end()
154
                ->end()
155
            ->end()
156
        ;
157
158
        return $treeBuilder;
159
    }
160
}
161