WidgetExtensionFormSections   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 0 30 1
1
<?php namespace Anomaly\DashboardModule\Widget\Extension\Form;
2
3
/**
4
 * Class WidgetExtensionFormSections
5
 *
6
 * @link          http://pyrocms.com/
7
 * @author        PyroCMS, Inc. <[email protected]>
8
 * @author        Ryan Thompson <[email protected]>
9
 */
10
class WidgetExtensionFormSections
11
{
12
13
    /**
14
     * Handle the form sections.
15
     *
16
     * @param WidgetExtensionFormBuilder $builder
17
     */
18
    public function handle(WidgetExtensionFormBuilder $builder)
19
    {
20
        $widget        = $builder->getChildForm('widget');
21
        $configuration = $builder->getChildForm('configuration');
22
23
        $builder->setSections(
24
            [
25
                [
26
                    'fields' => function () use ($widget) {
27
                        return array_map(
28
                            function ($field) {
29
                                return 'widget_' . $field;
30
                            },
31
                            $widget->getFormFieldSlugs()
32
                        );
33
                    },
34
                ],
35
                [
36
                    'fields' => function () use ($configuration) {
37
                        return array_map(
38
                            function ($field) {
39
                                return 'configuration_' . $field;
40
                            },
41
                            $configuration->getFormFieldSlugs()
42
                        );
43
                    },
44
                ],
45
            ]
46
        );
47
    }
48
}
49