Completed
Push — master ( 3c8880...e2c218 )
by Dmitry
06:42 queued 02:46
created

PrepareAjaxViewAction::getDefaultRules()   B

Complexity

Conditions 2
Paths 1

Size

Total Lines 26
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 26
ccs 0
cts 24
cp 0
rs 8.8571
cc 2
eloc 16
nc 1
nop 0
crap 6
1
<?php
2
3
/*
4
 * HiPanel core package
5
 *
6
 * @link      https://hipanel.com/
7
 * @package   hipanel-core
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hipanel\actions;
13
14
/**
15
 * Class PrepareAjaxViewAction.
16
 */
17
class PrepareAjaxViewAction extends ViewAction
18
{
19
    /** {@inheritdoc} */
20
    protected function getDefaultRules()
21
    {
22
        return array_merge(parent::getDefaultRules(), [
23
            'ajax' => [
24
                'save' => true,
25
                'flash' => false,
26
                'success' => [
27
                    'class' => RenderAjaxAction::class,
28
                    'view' => $this->view,
29
                    'data' => function () {
30
                        return $this->prepareData();
31
                    },
32
                    'params' => function () {
33
                        foreach ($this->collection->models as $model) {
34
                            $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...
35
                        }
36
37
                        return [
38
                            'models' => $this->collection->models,
39
                            'model' => $this->collection->first,
40
                        ];
41
                    },
42
                ],
43
            ],
44
        ]);
45
    }
46
}
47