Completed
Push — master ( a52bcf...c080ac )
by Dmitry
04:27
created

ReminderController::actions()   B

Complexity

Conditions 2
Paths 1

Size

Total Lines 43
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 3
Bugs 0 Features 2
Metric Value
cc 2
eloc 26
c 3
b 0
f 2
nc 1
nop 0
dl 0
loc 43
ccs 0
cts 39
cp 0
crap 6
rs 8.8571
1
<?php
2
3
namespace hipanel\controllers;
4
5
use hipanel\actions\IndexAction;
6
use hipanel\actions\OrientationAction;
7
use hipanel\actions\SmartCreateAction;
8
use hipanel\actions\SmartDeleteAction;
9
use hipanel\actions\SmartUpdateAction;
10
use yii\web\NotFoundHttpException;
11
12
class ReminderController extends \hipanel\base\CrudController
13
{
14
    public function init()
15
    {
16
        $this->viewPath = '@hipanel/views/reminder';
17
    }
18
19
    public function actions()
20
    {
21
        return [
22
            'set-orientation' => [
23
                'class' => OrientationAction::class,
24
                'allowedRoutes' => [
25
                    'reminder/index'
26
                ]
27
            ],
28
            'index' => [
29
                'class' => IndexAction::class,
30
                'data' => function ($action, $data) {
0 ignored issues
show
Unused Code introduced by
The parameter $action is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $data is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
                    return [
32
33
                    ];
34
                },
35
            ],
36
            'create-modal' => [
37
                'class' => SmartCreateAction::class,
38
                'scenario' => 'create',
39
                'view' => 'create-modal',
40
                'data' => function ($action, $data) {
41
                    $object_id = \Yii::$app->request->get('object_id');
42
                    if (empty($object_id)) {
43
                        throw new NotFoundHttpException('Object ID is missing');
44
                    }
45
46
                    $data['model']->object_id = $object_id;
47
48
                    return $data;
49
                }
50
            ],
51
            'create' => [
52
                'class' => SmartCreateAction::class,
53
            ],
54
            'update' => [
55
                'class' => SmartUpdateAction::class,
56
            ],
57
            'delete' => [
58
                'class' => SmartDeleteAction::class,
59
            ]
60
        ];
61
    }
62
63
    /**
64
     * @return array
65
     */
66
    protected function prepareRefs()
67
    {
68
        return [
69
            'topic_data' => $this->getRefs('topic,ticket', 'hipanel/ticket'),
70
            'state_data' => $this->getClassRefs('state', 'hipanel/ticket'),
71
            'priority_data' => $this->getPriorities(),
0 ignored issues
show
Documentation Bug introduced by
The method getPriorities does not exist on object<hipanel\controllers\ReminderController>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
72
        ];
73
    }
74
}
75