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

XEditableAction   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadCollection() 0 10 2
A run() 0 8 2
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 hipanel\helpers\ArrayHelper;
15
use Yii;
16
17
/**
18
 * Class XEditableAction.
19
 */
20
class XEditableAction extends Action
21
{
22
    public function loadCollection($data = null)
23
    {
24
        if (is_null($data)) {
25
            $data = \Yii::$app->request->post();
26
        }
27
        return parent::loadCollection([[
28
            'id'          => ArrayHelper::remove($data, 'pk'),
29
            $data['name'] => ArrayHelper::remove($data, 'value', []),
30
        ]]);
31
    }
32
33
    public function run()
34
    {
35
        $error = $this->perform();
36
        if ($error) {
37
            Yii::$app->response->statusCode = 400;
38
        }
39
        return $error;
40
    }
41
}
42