Configuration   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 196
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 7
eloc 155
c 4
b 0
f 0
dl 0
loc 196
ccs 154
cts 154
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A addDatasourcesSection() 0 32 1
A getConfigTreeBuilder() 0 12 1
A addAreabrickSection() 0 15 1
A addCommonAreabrick() 0 36 1
A addDatasourcesAreabrick() 0 25 1
A addGroupsAreabrick() 0 7 1
A addEditableAreabrick() 0 52 1
1
<?php
2
3
namespace Khusseini\PimcoreRadBrickBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
6
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
7
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
8
use Symfony\Component\Config\Definition\ConfigurationInterface;
9
10
/**
11
 * This is the class that validates and merges configuration from your app/config files.
12
 *
13
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
14
 */
15
class Configuration implements ConfigurationInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20 3
    public function getConfigTreeBuilder()
21
    {
22 3
        $treeBuilder = new TreeBuilder();
23
        /**
24
         * @var ArrayNodeDefinition
25
         */
26 3
        $rootNode = $treeBuilder->root('pimcore_rad_brick');
0 ignored issues
show
Deprecated Code introduced by
The function Symfony\Component\Config...der\TreeBuilder::root() has been deprecated: since Symfony 4.3, pass the root name to the constructor instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

26
        $rootNode = /** @scrutinizer ignore-deprecated */ $treeBuilder->root('pimcore_rad_brick');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
27
28 3
        $this->addDatasourcesSection($rootNode);
29 3
        $this->addAreabrickSection($rootNode);
30
31 3
        return $treeBuilder;
32
    }
33
34 3
    protected function addCommonAreabrick(NodeBuilder $builder): void
35
    {
36
        $builder
37 3
            ->scalarNode('class')
38 3
            ->info('Use a predefined service instead of a newly created one.')
39 3
            ->end();
40
        $builder
41 3
            ->arrayNode('options')
42 3
                ->info('Set options for areabrick. (Makes only sense in combination with `class`)')
43 3
                ->useAttributeAsKey('name')
44 3
                ->scalarPrototype()
45 3
                ->end()
46 3
            ->end();
0 ignored issues
show
Bug introduced by
The method end() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Symfony\Component\Config...ion\Builder\TreeBuilder. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
            ->/** @scrutinizer ignore-call */ end();
Loading history...
47
        $builder
48 3
            ->scalarNode('label')
49 3
            ->info('Specify a label for the admin UI.')
50 3
            ->end();
51
        $builder
52 3
            ->scalarNode('icon')
53 3
            ->info('Specify an icon for the admin UI.')
54 3
            ->end();
55
        $builder
56 3
            ->scalarNode('open')
57 3
            ->info('Set HTML prepended to the brick\'s contents.')
58 3
            ->defaultValue('')
59 3
            ->end();
60
        $builder
61 3
            ->scalarNode('close')
62 3
            ->info('Set HTML appended to the brick\'s contents.')
63 3
            ->defaultValue('')
64 3
            ->end();
65
        $builder
66 3
            ->booleanNode('use_edit')
67 3
            ->info('Use a separate edit template.')
68 3
            ->defaultValue(false)
69 3
            ->end();
70 3
    }
71
72 3
    protected function addGroupsAreabrick(NodeBuilder $builder): void
73
    {
74
        $builder
75 3
            ->variableNode('groups')
76 3
            ->info('Define groups for areabrick.')
77 3
            ->defaultValue([])
78 3
            ->end();
79 3
    }
80
81 3
    protected function addDatasourcesAreabrick(NodeBuilder $builder): void
82
    {
83
        $builder
84 3
            ->arrayNode('datasources')
85 3
                ->info('Configure datasources to use  in view template')
86 3
                ->useAttributeAsKey('name')
87 3
                ->arrayPrototype()
88 3
                    ->children()
89 3
                        ->scalarNode('id')
90 3
                            ->info('Provide the id of the datasource to use')
91 3
                        ->end()
92 3
                        ->arrayNode('conditions')
0 ignored issues
show
Bug introduced by
The method arrayNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

92
                        ->/** @scrutinizer ignore-call */ arrayNode('conditions')
Loading history...
93 3
                            ->info('Configure conditions for datasource.')
94 3
                            ->scalarPrototype()
95 3
                            ->end()
96 3
                        ->end()
97 3
                        ->arrayNode('args')
98 3
                            ->info('Configure arguments to pass to method call')
99 3
                            ->useAttributeAsKey('name')
100 3
                            ->variablePrototype()
101 3
                            ->end()
102 3
                        ->end()
103 3
                    ->end()
104 3
                ->end()
105 3
            ->end();
106 3
    }
107
108 3
    protected function addEditableAreabrick(NodeBuilder $builder): void
109
    {
110
        $builder
111 3
            ->arrayNode('editables')
112 3
            ->info('Define editables available in templates.')
113 3
            ->requiresAtLeastOneElement()
114 3
            ->useAttributeAsKey('name')
115 3
            ->arrayPrototype()
116 3
            ->children()
117 3
            ->scalarNode('type')
118 3
            ->info('Editable type')
119 3
            ->isRequired()
120 3
            ->cannotBeEmpty()
121 3
            ->end()
122 3
            ->variableNode('options')
0 ignored issues
show
Bug introduced by
The method variableNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

122
            ->/** @scrutinizer ignore-call */ variableNode('options')
Loading history...
123 3
            ->info('Editable options')
124 3
            ->defaultValue([])
125 3
            ->end()
126 3
            ->scalarNode('instances')
127 3
            ->info('Provide the number of instances.')
128 3
            ->end()
129 3
            ->scalarNode('group')
130 3
            ->info('Specify the name of the group this editable belongs to.')
131 3
            ->end()
132 3
            ->arrayNode('map')
133 3
            ->info('Map data from other editables')
134 3
            ->arrayPrototype()
135 3
            ->children()
136 3
            ->scalarNode('source')
137 3
            ->info('Expression to get the value')
138 3
            ->isRequired()
139 3
            ->cannotBeEmpty()
140 3
            ->end()
141 3
            ->scalarNode('target')
142 3
            ->info('Path to property to be updated')
143 3
            ->isRequired()
144 3
            ->cannotBeEmpty()
145 3
            ->end()
146 3
            ->end()
147 3
            ->end()
148 3
            ->end()
149 3
            ->arrayNode('datasource')
150 3
            ->info('Bind editable to a datasource')
151 3
            ->children()
152 3
            ->scalarNode('name')
153 3
            ->info('The name of the datasource')
154 3
            ->end()
155 3
            ->scalarNode('id')
156 3
            ->info('The id to use for each item (uses expression language)')
157 3
            ->end()
158 3
            ->end()
159 3
            ->end();
160 3
    }
161
162 3
    protected function addAreabrickSection(ArrayNodeDefinition $node): void
163
    {
164
        $prototype = $node
165 3
            ->children()
166 3
            ->arrayNode('areabricks')
167 3
            ->useAttributeAsKey('name')
168 3
            ->arrayPrototype()
169 3
            ->children();
170
171 3
        $this->addCommonAreabrick($prototype);
172 3
        $this->addGroupsAreabrick($prototype);
173 3
        $this->addDatasourcesAreabrick($prototype);
174 3
        $this->addEditableAreabrick($prototype);
175
176 3
        $prototype->end()->end()->end();
177 3
    }
178
179 3
    protected function addDatasourcesSection(ArrayNodeDefinition $node): void
180
    {
181
        $node
182 3
            ->children()
183 3
            ->arrayNode('datasources')
184 3
            ->info('Define datasource available in areabricks.')
185 3
            ->useAttributeAsKey('name')
186 3
            ->arrayPrototype()
187 3
            ->children()
188
189 3
            ->scalarNode('service_id')
190 3
            ->info('Provide a Symfony service id')
191 3
            ->isRequired()
192 3
            ->cannotBeEmpty()
193 3
            ->end()
194
195 3
            ->scalarNode('method')
0 ignored issues
show
Bug introduced by
The method scalarNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

195
            ->/** @scrutinizer ignore-call */ scalarNode('method')
Loading history...
196 3
            ->info('Method to be called on service')
197 3
            ->isRequired()
198 3
            ->cannotBeEmpty()
199 3
            ->end()
200
201 3
            ->arrayNode('args')
202 3
            ->variablePrototype()
203 3
            ->info('Method arguments. Expressions can be used here')
204 3
            ->end()
205 3
            ->end()
206
207 3
            ->end()
208 3
            ->end()
209 3
            ->end()
210 3
            ->end();
211 3
    }
212
}
213