Completed
Push — master ( ade816...2e2eaf )
by Dmitry
05:09 queued 01:21
created

ReminderController::getPeriodicityOptions()   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 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
1
<?php
2
3
namespace hipanel\controllers;
4
5
use hipanel\actions\IndexAction;
6
use hipanel\actions\OrientationAction;
7
use hipanel\actions\RedirectAction;
8
use hipanel\actions\RenderAjaxAction;
9
use hipanel\actions\RenderJsonAction;
10
use hipanel\actions\SmartCreateAction;
11
use hipanel\actions\SmartDeleteAction;
12
use hipanel\actions\SmartUpdateAction;
13
use hipanel\actions\ValidateFormAction;
14
use yii\web\NotFoundHttpException;
15
16
class ReminderController extends \hipanel\base\CrudController
17
{
18
    public function init()
19
    {
20
        $this->viewPath = '@hipanel/views/reminder';
21
    }
22
23
    public function actions()
24
    {
25
        return [
26
            'set-orientation' => [
27
                'class' => OrientationAction::class,
28
                'allowedRoutes' => [
29
                    'reminder/index'
30
                ]
31
            ],
32
            'validate-form' => [
33
                'class' => ValidateFormAction::class,
34
            ],
35
            'index' => [
36
                'class' => IndexAction::class,
37
                '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...
38
                    return [
39
40
                    ];
41
                },
42
            ],
43
            'create-modal' => [
44
                'class' => SmartCreateAction::class,
45
                'scenario' => 'create',
46
                'view' => 'create-modal',
47
                'data' => function ($action, $data) {
48
                    $object_id = \Yii::$app->request->get('object_id');
49
                    if (empty($object_id)) {
50
                        throw new NotFoundHttpException('Object ID is missing');
51
                    }
52
                    $data['model']->object_id = $object_id;
53
54
                    return $data;
55
                },
56
            ],
57
            'create' => [
58
                'class' => SmartCreateAction::class,
59
                'view' => 'create-modal',
60
            ],
61
            'update' => [
62
                'class' => SmartUpdateAction::class,
63
            ],
64
            'delete' => [
65
                'class' => SmartDeleteAction::class,
66
                'POST html | POST pjax' => [
67
                    'save' => true,
68
                    'success' => [
69
                        'class' => RedirectAction::class,
70
                    ],
71
                ],
72
            ]
73
        ];
74
    }
75
76
    public function getPeriodicityOptions()
77
    {
78
        return $this->getRefs('type,periodicity', 'hipanel/reminder');
79
    }
80
}
81