Completed
Push — master ( 5a0a6c...47e90b )
by Andrii
05:24
created

ClassValuesAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 32
ccs 0
cts 18
cp 0
rs 10
wmc 3
lcom 1
cbo 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 23 3
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
use hiqdev\hiart\Collection;
15
use Closure;
16
use Yii;
17
18
/**
19
 * Class ClassValuesAction.
20
 */
21
class ClassValuesAction extends Action
22
{
23
    public $valuesClass;
24
25
    public $view;
26
27
    public $model;
28
29
    public function run($id)
30
    {
31
        $this->model = $this->controller->findModel($id);
32
        $this->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...
33
        $request = Yii::$app->request;
34
35
        if ($request->isAjax && Yii::$app->request->isPost) {
36
37
            /// to be redone with native Action collection
38
            $this->model = (new Collection(['model' => $this->model]))->load()->first;
39
40
            $this->beforePerform();
41
            $this->model->perform('SetClassValues', [
42
                'id'     => $id,
43
                'class'  => $this->valuesClass,
44
                'values' => $this->model->dirtyAttributes,
45
            ]);
46
            Yii::$app->end();
47
        }
48
        $this->model->setAttributes($this->model->perform('GetClassValues', ['id' => $id, 'class' => $this->valuesClass]));
49
50
        return $this->controller->renderAjax($this->view, ['model' => $this->model]);
51
    }
52
}
53