ProfileController::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace Itstructure\RbacModule\controllers;
4
5
/**
6
 * Class ProfileController
7
 * ProfileController implements the CRUD actions for identityClass.
8
 *
9
 * @package Itstructure\RbacModule\controllers
10
 */
11
class ProfileController extends BaseController
12
{
13
    /**
14
     * Initialize.
15
     * Set validateComponent and additionFields.
16
     */
17
    public function init()
18
    {
19
        $this->viewPath = '@rbac/views/profiles';
20
21
        $this->validateComponent = $this->module->get('profile-validate-component');
22
23
        parent::init();
24
    }
25
26
    /**
27
     * Returns addition fields.
28
     *
29
     * @return array
30
     */
31
    protected function getAdditionFields(): array
32
    {
33
        $additionFields = [];
34
35
        if ($this->action->id == 'update') {
36
            $additionFields['roles'] = $this->validateComponent->getAuthManager()->getRoles();
37
        }
38
39
        return $additionFields;
40
    }
41
42
    /**
43
     * Returns identityClass model name.
44
     *
45
     * @return string
46
     */
47
    protected function getModelName(): string
48
    {
49
        return \Yii::$app->user->identityClass;
50
    }
51
52
    /**
53
     * Returns identityClass Search model name.
54
     *
55
     * @return string
56
     */
57
    protected function getSearchModelName(): string
58
    {
59
        return \Yii::$app->user->identityClass . 'Search';
60
    }
61
}
62