RrdController::behaviors()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
c 0
b 0
f 0
ccs 0
cts 7
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Server module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-server
6
 * @package   hipanel-module-server
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\server\controllers;
12
13
use hipanel\actions\IndexAction;
14
use hipanel\base\CrudController;
15
use hipanel\filters\EasyAccessControl;
16
use yii\base\Event;
17
18
class RrdController extends CrudController
19
{
20
    public function behaviors()
21
    {
22
        return array_merge(parent::behaviors(), [
23
            [
24
                'class' => EasyAccessControl::class,
25
                'actions' => [
26
                    '*' => 'server.read',
27
                ],
28
            ],
29
        ]);
30
    }
31
32
    public function actions()
33
    {
34
        return [
35
            'view' => [
36
                'class' => IndexAction::class,
37
                'on beforePerform' => function (Event $event) {
38
                    /** @var \hipanel\actions\SearchAction $action */
39
                    $action = $event->sender;
40
                    $dataProvider = $action->getDataProvider();
41
                    $dataProvider->query->joinWith('images');
42
                    $dataProvider->query->joinWith('server');
43
                    $dataProvider->pagination = false;
44
                },
45
                'collection' => [
46
                    'formName' => '',
47
                ],
48
            ],
49
        ];
50
    }
51
}
52