Completed
Push — master ( b1d78b...f115f6 )
by Dmitry
04:40
created

CrudController::getPriorities()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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\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, $translate = null, $options = [])
30
    {
31
        return Ref::getList($name, $translate, $options);
32
    }
33
34
    public function getClassRefs($type, $translate = null, $options = [])
35
    {
36
        return $this->getRefs($type . ',' . static::modelId('_'), $translate, $options);
37
    }
38
39
    public function getBlockReasons()
40
    {
41
        return $this->getRefs('type,block', 'hipanel');
42
    }
43
}
44