Issues (33)

views/layouts/main.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * @var $this \yii\web\View
5
 * @var $content string
6
 */
7
8
use app\widgets\Alert;
9
use yii\helpers\Html;
10
use yii\bootstrap\Nav;
11
use yii\bootstrap\NavBar;
12
use yii\widgets\Breadcrumbs;
13
use app\assets\AppAsset;
14
use modules\main\Module as MainModule;
15
use modules\users\Module as UserModule;
16
use modules\admin\Module as AdminModule;
17
18
AppAsset::register($this);
19
?>
20
<?php $this->beginPage() ?>
21
<!DOCTYPE html>
22
<html lang="<?= Yii::$app->language ?>">
23
<head>
24
    <meta charset="<?= Yii::$app->charset ?>">
25
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
26
    <meta name="viewport" content="width=device-width, initial-scale=1">
27
    <?= Html::csrfMetaTags() ?>
28
    <title><?= Yii::$app->name . ' | ' . Html::encode($this->title) ?></title>
29
    <?php $this->head() ?>
30
</head>
31
<body>
32
<?php $this->beginBody() ?>
33
34
<div class="wrap">
35
    <?php
36
    NavBar::begin([
37
        'brandLabel' => Html::img('@web/images/logo.png', ['alt' => Yii::$app->name, 'class' => 'yii-logo']) . Yii::$app->name,
38
        'brandUrl' => Yii::$app->homeUrl,
39
        'options' => [
40
            'class' => 'navbar-inverse navbar-fixed-top',
41
        ],
42
    ]);
43
    $menuItems = [
44
        [
45
            'label' => MainModule::t('module', 'Home'),
46
            'url' => ['/main/default/index']
47
        ],
48
        [
49
            'label' => MainModule::t('module', 'About'),
50
            'url' => ['/main/default/about']
51
        ],
52
        [
53
            'label' => MainModule::t('module', 'Contact'),
54
            'url' => ['/main/default/contact']
55
        ],
56
    ];
57
    if (Yii::$app->user->isGuest) {
58
        $menuItems[] = ['label' => UserModule::t('module', 'Check in'), 'url' => ['/users/default/signup']];
59
        $menuItems[] = [
60
            'label' => UserModule::t('module', 'Login'),
61
            'url' => ['/users/default/login']
62
        ];
63
    } else {
64
        /** @var modules\users\models\User $identity */
65
        $identity = Yii::$app->user->identity;
66
        $menuItems[] = [
67
            'label' => UserModule::t('module', 'My Menu'),
68
            'items' => [
69
                [
70
                    'label' => '<i class="glyphicon glyphicon-queen"></i> ' . AdminModule::t('module', 'Administration'),
71
                    'url' => ['/admin/default/index'],
72
                    'visible' => Yii::$app->user->can(\modules\rbac\models\Permission::PERMISSION_VIEW_ADMIN_PAGE),
0 ignored issues
show
The method can() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

72
                    'visible' => Yii::$app->user->/** @scrutinizer ignore-call */ can(\modules\rbac\models\Permission::PERMISSION_VIEW_ADMIN_PAGE),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
73
                ],
74
                [
75
                    'label' => '<i class="glyphicon glyphicon-lock"></i> ' . AdminModule::t('rbac', 'RBAC'),
76
                    'url' => ['/rbac/default/index'],
77
                    'visible' => Yii::$app->user->can(\modules\rbac\models\Permission::PERMISSION_MANAGER_RBAC),
78
                ],
79
                [
80
                    'label' => '<i class="glyphicon glyphicon-eye-open"></i> ' . UserModule::t('module', 'Profile') . ' (' . $identity->username . ')',
81
                    'url' => ['/users/profile/index'],
82
                ],
83
                [
84
                    'label' => '<i class="glyphicon glyphicon-log-out"></i> ' . UserModule::t('module', 'Sign Out'),
85
                    'url' => ['/users/default/logout'],
86
                    'linkOptions' => [
87
                        'data-method' => 'post'
88
                    ]
89
                ],
90
            ],
91
        ];
92
    }
93
    echo Nav::widget([
94
        'options' => ['class' => 'navbar-nav navbar-right'],
95
        'activateParents' => true,
96
        'encodeLabels' => false,
97
        'items' => array_filter($menuItems)
98
    ]);
99
    NavBar::end();
100
    ?>
101
102
    <div class="container">
103
        <?= Breadcrumbs::widget([
104
            'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
105
        ]) ?>
106
        <?= Alert::widget() ?>
107
        <?= $content ?>
108
    </div>
109
</div>
110
111
<footer class="footer">
112
    <div class="container">
113
        <p class="pull-left">&copy; <?= Yii::$app->name . ' ' . date('Y') ?></p>
114
115
        <p class="pull-right">Powered by <a href="http://www.yiiframework.com/" target="_blank">Yii Framework</a></p>
116
    </div>
117
</footer>
118
119
<?php $this->endBody() ?>
120
</body>
121
</html>
122
<?php $this->endPage() ?>
123