Completed
Push — master ( ee406a...a0eb04 )
by Klochok
14:02
created

DashboardItem::items()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 10
cp 0
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Domain plugin for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-domain
6
 * @package   hipanel-module-domain
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\ticket\menus;
12
13
use hipanel\helpers\Url;
14
use hipanel\modules\client\ClientWithCounters;
15
use hiqdev\yii2\menus\Menu;
16
use Yii;
17
18
class DashboardItem extends Menu
19
{
20
    protected ClientWithCounters $clientWithCounters;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
21
22
    public function __construct(ClientWithCounters $clientWithCounters, $config = [])
23
    {
24
        $this->clientWithCounters = $clientWithCounters;
25
        parent::__construct($config);
26
    }
27
28
    public function items()
29
    {
30
        return Yii::$app->user->can('ticket.read') ? [
31
            'ticket' => [
32
                'label' => $this->render('dashboardItem', array_merge($this->clientWithCounters->getWidgetData('ticket'), [
33
                    'route' => Url::toRoute('@ticket/index'),
34
                ])),
35
                'encode' => false,
36
            ],
37
        ] : [];
38
    }
39
}
40