onSavingConfiguration()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 6
nc 2
nop 0
1
<?php namespace Anomaly\DashboardModule\Widget\Extension\Form;
2
3
use Anomaly\ConfigurationModule\Configuration\Form\ConfigurationFormBuilder;
4
use Anomaly\DashboardModule\Widget\Contract\WidgetInterface;
5
use Anomaly\DashboardModule\Widget\Form\WidgetFormBuilder;
6
use Anomaly\Streams\Platform\Ui\Form\Multiple\MultipleFormBuilder;
7
8
/**
9
 * Class WidgetExtensionFormBuilder
10
 *
11
 * @link          http://pyrocms.com/
12
 * @author        PyroCMS, Inc. <[email protected]>
13
 * @author        Ryan Thompson <[email protected]>
14
 */
15
class WidgetExtensionFormBuilder extends MultipleFormBuilder
16
{
17
18
    /**
19
     * Fired just before saving the configuration.
20
     */
21
    public function onSavingConfiguration()
22
    {
23
        /* @var WidgetFormBuilder $form */
24
        $form = $this->forms->get('widget');
25
26
        /* @var WidgetInterface $widget */
27
        $widget = $form->getFormEntry();
28
29
        /* @var ConfigurationFormBuilder $configuration */
30
        $configuration = $this->forms->get('configuration');
31
32
        if (!$configuration->getScope()) {
33
            $configuration->setScope($widget->getId());
34
        }
35
    }
36
}
37