These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * HiPanel tickets module |
||
4 | * |
||
5 | * @link https://github.com/hiqdev/hipanel-module-ticket |
||
6 | * @package hipanel-module-ticket |
||
7 | * @license BSD-3-Clause |
||
8 | * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) |
||
9 | */ |
||
10 | |||
11 | namespace hipanel\modules\ticket\controllers; |
||
12 | |||
13 | use hipanel\actions\IndexAction; |
||
14 | use hipanel\modules\ticket\models\Statistic; |
||
15 | use hipanel\filters\EasyAccessControl; |
||
16 | use yii\base\Event; |
||
17 | |||
18 | class StatisticController extends \hipanel\base\CrudController |
||
19 | { |
||
20 | View Code Duplication | public function behaviors() |
|
0 ignored issues
–
show
|
|||
21 | { |
||
22 | return array_merge(parent::behaviors(), [ |
||
23 | [ |
||
24 | 'class' => EasyAccessControl::class, |
||
25 | 'actions' => [ |
||
26 | '*' => 'manage', |
||
27 | ], |
||
28 | |||
29 | ], |
||
30 | ]); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * @return array |
||
35 | */ |
||
36 | View Code Duplication | protected function prepareRefs() |
|
0 ignored issues
–
show
This method 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. ![]() |
|||
37 | { |
||
38 | return [ |
||
39 | 'topic_data' => $this->getRefs('topic,ticket', 'hipanel:ticket'), |
||
40 | 'state_data' => $this->getClassRefs('state', 'hipanel:ticket'), |
||
41 | 'priority_data' => $this->getRefs('type,priority', 'hipanel:ticket'), |
||
42 | ]; |
||
43 | } |
||
44 | |||
45 | public function actions() |
||
46 | { |
||
47 | return [ |
||
48 | 'index' => [ |
||
49 | 'class' => IndexAction::class, |
||
50 | 'data' => $this->prepareRefs(), |
||
51 | 'on beforePerform' => function (Event $event) { |
||
52 | $action = $event->sender; |
||
53 | $query = $action->getDataProvider()->query; |
||
54 | $representation = $action->controller->indexPageUiOptionsModel->representation; |
||
55 | if ($representation === 'consumers') { |
||
56 | $query->andWhere(['type' => 'consumers']); |
||
57 | } else { |
||
58 | $query->andWhere(['type' => 'performers']); |
||
59 | } |
||
60 | } |
||
61 | ], |
||
62 | ]; |
||
63 | } |
||
64 | } |
||
65 |
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.