Completed
Push — master ( 3cd595...855c14 )
by Andrii
04:32
created

CrudController   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A hasAction() 0 9 3
A getRefs() 0 4 1
A getClassRefs() 0 4 1
A getBlockReasons() 0 4 1
A getPriorities() 0 4 1
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\base;
13
14
use hipanel\models\Ref;
15
use yii\helpers\Inflector;
16
17
class CrudController extends Controller
18
{
19
    public function hasAction($id, $actions = null)
20
    {
21
        if (is_null($actions)) {
22
            $actions = $this->actions();
23
        }
24
        $method = 'action' . Inflector::id2camel($id);
25
26
        return isset($actions[$id]) || method_exists($this, $method);
27
    }
28
29
    public function getRefs($name, $options = [], $translate = 'app')
30
    {
31
        return Ref::getList($name, $options, $translate);
32
    }
33
34
    public function getClassRefs($type)
35
    {
36
        return $this->getRefs($type . ',' . static::modelId('_'));
37
    }
38
39
    public function getBlockReasons()
40
    {
41
        return Ref::getList('type,block');
42
    }
43
44
    public function getPriorities()
45
    {
46
        return Ref::getList('type,priority');
47
    }
48
}
49