DbManager::getChildrenList()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
c 0
b 0
f 0
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace toir427\admin\components;
4
5
/**
6
 * DbManager represents an authorization manager that stores authorization information in database.
7
 *
8
 * The database connection is specified by [[$db]]. The database schema could be initialized by applying migration:
9
 *
10
 * ```
11
 * yii migrate --migrationPath=@yii/rbac/migrations/
12
 * ```
13
 *
14
 * If you don't want to use migration and need SQL instead, files for all databases are in migrations directory.
15
 *
16
 * You may change the names of the three tables used to store the authorization data by setting [[\yii\rbac\DbManager::$itemTable]],
17
 * [[\yii\rbac\DbManager::$itemChildTable]] and [[\yii\rbac\DbManager::$assignmentTable]].
18
 *
19
 * @author Misbahul D Munir <[email protected]>
20
 * @since 1.0
21
 */
22
class DbManager extends \yii\rbac\DbManager
23
{
24
    /**
25
     * Memory cache of assignments
26
     * @var array
27
     */
28
    private $_assignments = [];
29
    private $_childrenList;
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function getAssignments($userId)
35
    {
36
        if (!isset($this->_assignments[$userId])) {
37
            $this->_assignments[$userId] = parent::getAssignments($userId);
38
        }
39
        return $this->_assignments[$userId];
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45
    protected function getChildrenList()
46
    {
47
        if ($this->_childrenList === null) {
48
            $this->_childrenList = parent::getChildrenList();
49
        }
50
        return $this->_childrenList;
51
    }
52
}
53