| Conditions | 2 |
| Paths | 2 |
| Total Lines | 29 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | <?php |
||
| 7 | public function up() |
||
| 8 | { |
||
| 9 | $auth = Yii::$app->authManager; |
||
| 10 | |||
| 11 | if ($auth instanceof \yii\rbac\DbManager) { |
||
| 12 | $guest = $auth->createRole('Public'); |
||
| 13 | $guest->description = 'Unauthenticated User'; |
||
| 14 | $auth->add($guest); |
||
| 15 | |||
| 16 | $editor = $auth->createRole('Editor'); |
||
| 17 | $editor->description = 'prototype editor'; |
||
| 18 | $auth->add($editor); |
||
| 19 | |||
| 20 | $permission = $auth->createPermission('backend_default'); |
||
| 21 | $permission->description = 'Backend Dashboard'; |
||
| 22 | $auth->add($permission); |
||
| 23 | |||
| 24 | $permission = $auth->createPermission('app_site'); |
||
| 25 | $permission->description = 'Main Site Controller'; |
||
| 26 | $auth->add($permission); |
||
| 27 | |||
| 28 | $auth->addChild($editor, $auth->getPermission('backend_default')); |
||
| 29 | $auth->addChild($editor, $auth->getPermission('app_site')); |
||
| 30 | |||
| 31 | $auth->addChild($editor, $auth->getPermission('pages')); |
||
| 32 | } else { |
||
| 33 | throw new \yii\base\Exception('Application authManager must be an instance of \yii\rbac\DbManager'); |
||
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 51 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.