Issues (1256)

traits/AdminBeforeActionTrait.php (2 issues)

1
<?php
2
3
namespace app\traits;
4
5
use Yii;
6
use Itstructure\AdminModule\components\AdminView;
7
8
/**
9
 * Class AdminBeforeActionTrait
10
 *
11
 * @property AdminView $view
12
 *
13
 * @package app\traits
14
 */
15
trait AdminBeforeActionTrait
16
{
17
    /**
18
     * @var array
19
     */
20
    private $neighborControllers = [
21
        'profiles' => 'roles',
22
        'roles' => 'permissions',
23
    ];
24
25
    /**
26
     * @param \yii\base\Action $action
27
     *
28
     * @return bool
29
     */
30
    public function beforeAction($action)
31
    {
32
        $this->view->mainMenuConfig = require __DIR__ . '/../config/admin/main-menu.php';
33
34
        $this->view->profileLink = '/admin/users/view?id='.Yii::$app->getUser()->id;
35
36
        $this->urlPrefix = '/' . $this->module->id . '/' . $action->controller->id . '/';
0 ignored issues
show
Bug Best Practice introduced by
The property urlPrefix does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
37
38
        if (array_key_exists($action->controller->id, $this->neighborControllers)) {
39
            $this->urlPrefixNeighbor = '/' . $this->module->id . '/' . $this->neighborControllers[$action->controller->id] . '/';
0 ignored issues
show
Bug Best Practice introduced by
The property urlPrefixNeighbor does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
40
        }
41
42
        return parent::beforeAction($action);
43
    }
44
}