Total Complexity | 7 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class RoleFilter extends Filter |
||
14 | { |
||
15 | /** |
||
16 | * @var array|string |
||
17 | */ |
||
18 | public $roles; |
||
19 | /** |
||
20 | * @var User |
||
21 | */ |
||
22 | protected $user; |
||
23 | |||
24 | /** |
||
25 | * @inheritdoc |
||
26 | */ |
||
27 | public function init() |
||
28 | { |
||
29 | $this->user = Yii::$app->user; |
||
30 | if (is_string($this->roles)) { |
||
31 | $this->roles = [$this->roles]; |
||
32 | } |
||
33 | parent::init(); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @return bool |
||
38 | */ |
||
39 | public function isAllowed() |
||
49 | } |
||
50 | } |
||
51 |