1 | <?php |
||
18 | class AuthItem extends \yii\db\ActiveRecord |
||
19 | { |
||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | public $roles; |
||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | public $permissions; |
||
28 | |||
29 | /** |
||
30 | * @inheritdoc |
||
31 | */ |
||
32 | public static function tableName() |
||
33 | { |
||
34 | return Yii::$app->authManager->itemTable; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @inheritdoc |
||
39 | */ |
||
40 | public function rules() |
||
41 | { |
||
42 | return [ |
||
43 | [ |
||
44 | ['name', 'description'], 'required' |
||
45 | ], |
||
46 | [ |
||
47 | ['roles', 'permissions'], 'safe' |
||
48 | ], |
||
49 | |||
50 | ['name', 'unique'], |
||
51 | ['name', 'string', 'max' => 64], |
||
52 | ['name', 'match', 'pattern' => '/^[a-z]\w*$/i'], |
||
53 | ]; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @inheritdoc |
||
58 | */ |
||
59 | public function attributeLabels() |
||
60 | { |
||
61 | return [ |
||
62 | 'name' => Yii::t('app', 'Name'), |
||
63 | 'description' => Yii::t('app', 'Description'), |
||
64 | 'roles' => Yii::t('app', 'Inherit role'), |
||
65 | 'permissions' => Yii::t('app', 'Permissions'), |
||
66 | ]; |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @inheritdoc |
||
71 | * @codeCoverageIgnore |
||
72 | */ |
||
73 | public function events() |
||
79 | |||
80 | /** |
||
81 | * Is SuperUser? |
||
82 | * |
||
83 | * @return bool |
||
84 | */ |
||
85 | public function isSuperUser(): bool |
||
89 | |||
90 | /** |
||
91 | * Deleting a file from the db and from the file system |
||
92 | * |
||
93 | * @return bool |
||
94 | */ |
||
95 | public function beforeDelete() |
||
99 | } |
||
100 |