Completed
Pull Request — master (#19)
by
unknown
05:45
created

RrdController::actions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 12

Duplication

Lines 19
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 19
loc 19
ccs 0
cts 12
cp 0
rs 9.4285
cc 1
eloc 12
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-2017, 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 View Code Duplication
class RrdController extends CrudController
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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