PrepareAjaxViewAction   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDefaultRules() 0 26 2
1
<?php
2
/**
3
 * HiPanel core package
4
 *
5
 * @link      https://hipanel.com/
6
 * @package   hipanel-core
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2014-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\actions;
12
13
/**
14
 * Class PrepareAjaxViewAction.
15
 */
16
class PrepareAjaxViewAction extends ViewAction
17
{
18
    /** {@inheritdoc} */
19
    protected function getDefaultRules()
20
    {
21
        return array_merge(parent::getDefaultRules(), [
22
            'ajax' => [
23
                'save' => true,
24
                'flash' => false,
25
                'success' => [
26
                    'class' => RenderAjaxAction::class,
27
                    'view' => $this->view,
28
                    'data' => function () {
29
                        return $this->prepareData();
30
                    },
31
                    'params' => function () {
32
                        foreach ($this->collection->models as $model) {
33
                            $model->scenario = $this->scenario;
0 ignored issues
show
Bug introduced by
The property scenario does not seem to exist. Did you mean _scenario?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
34
                        }
35
36
                        return [
37
                            'models' => $this->collection->models,
38
                            'model' => $this->collection->first,
39
                        ];
40
                    },
41
                ],
42
            ],
43
        ]);
44
    }
45
}
46