Completed
Push — master ( edb2b9...da334f )
by Dmitry
13:12
created

src/actions/PrepareAjaxViewAction.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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