1 | <?php |
||
18 | class AuthDbManagerComponent extends DbManager implements AuthManagerInterface |
||
19 | { |
||
20 | /** |
||
21 | * @param int|null $type If null will return all auth items |
||
22 | * @param array $excludeItems Items that should be excluded from result array |
||
23 | * |
||
24 | * @return array |
||
25 | */ |
||
26 | public function getItems($type = null, $excludeItems = []) |
||
48 | |||
49 | /** |
||
50 | * Returns both roles and permissions assigned to user. |
||
51 | * |
||
52 | * @param int $userId |
||
53 | * |
||
54 | * @return array |
||
55 | */ |
||
56 | public function getItemsByUser($userId) |
||
57 | { |
||
58 | if (empty($userId)) { |
||
59 | return []; |
||
60 | } |
||
61 | |||
62 | $query = (new Query()) |
||
63 | ->select('b.*') |
||
64 | ->from(['a' => $this->assignmentTable, 'b' => $this->itemTable]) |
||
65 | ->where('{{a}}.[[item_name]]={{b}}.[[name]]') |
||
66 | ->andWhere(['a.user_id' => (string)$userId]); |
||
67 | |||
68 | $roles = []; |
||
69 | foreach ($query->all($this->db) as $row) { |
||
70 | $roles[$row['name']] = $this->populateItem($row); |
||
71 | } |
||
72 | |||
73 | return $roles; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | public function getItem($name) |
||
83 | } |
||
84 |