Completed
Push — master ( e1c233...726cec )
by Igor
07:28
created

UpdateAttributesAction::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace app\modules\admin\controllers\common;
4
5
use yii\base\Action;
6
7
class UpdateAttributesAction extends Action
8
{
9
    /**
10
     * @var string $modelName
11
     */
12
    public $modelName;
13
    /**
14
     * @var array $attributes
15
     */
16
    public $attributes;
17
18
    public function run($id)
19
    {
20
        $model = new $this->modelName();
21
22
        $model = $this->controller->loadModel($model, $id);
23
        $model->updateAttributes($this->attributes);
24
25
        return $this->controller->response(true);
26
    }
27
}
28