rbac/Rbac.php
private function initRolesForClass($access) {
    $auth = Yii::$app->authManager;
    $descriptions = $access->descriptions();
    foreach ($descriptions as $permissionName => $description) {
      $permission = $auth->getPermission($permissionName);
      if (!$permission) {
        $permission = $auth->createPermission($permissionName);
        $permission->description = $descriptions[$permissionName];
        $auth->add($permission);
      }
    }

    $rolesPermissions = $access->rolesPermissions();
    $rolesTitles = $access->rolesTitles();
    foreach ($rolesPermissions as $roleName => $permissions) {
      $role = $auth->getRole($roleName);
      if (!$role) {
        $role = $auth->createRole($roleName);
        $role->description = $rolesTitles[$roleName];
        $auth->add($role);
      }

      $oldPermissions = $auth->getPermissionsByRole($roleName);

      foreach ($permissions as $permissionName) {
        if (!isset($oldPermissions[$permissionName])) {
          $permission = $auth->getPermission($permissionName);
          $auth->addChild($role, $permission);
        }
      }
    }

  }
private function initRolesForClass($access) {
    $auth = Yii::$app->authManager;
    $descriptions = $access->descriptions();
    foreach ($descriptions as $permissionName => $description) {
      $permission = $auth->getPermission($permissionName);
      if (!$permission) {
        $permission = $auth->createPermission($permissionName);
        $permission->description = $descriptions[$permissionName];
        $auth->add($permission);
      }
    }

    $rolesPermissions = $access->rolesPermissions();
    $rolesTitles = $access->rolesTitles();
    foreach ($rolesPermissions as $roleName => $permissions) {
      $role = $auth->getRole($roleName);
      if (!$role) {
        $role = $auth->createRole($roleName);
        $role->description = $rolesTitles[$roleName];
        $auth->add($role);
      }

      $oldPermissions = $auth->getPermissionsByRole($roleName);

      foreach ($permissions as $permissionName) {
        if (!isset($oldPermissions[$permissionName])) {
          $permission = $auth->getPermission($permissionName);
          $auth->addChild($role, $permission);
        }
      }
    }

  }
private function initRolesForClass ( $ access ) { $ auth = Yii :: $ app -> authManager ; $ descriptions = $ access -> descriptions ( ) ; foreach ( $ descriptions as $ permissionName => $ description ) { $ permission = $ auth -> getPermission ( $ permissionName ) ; if ( ! $ permission ) { $ permission = $ auth -> createPermission ( $ permissionName ) ; $ permission -> description = $ descriptions [ $ permissionName ] ; $ auth -> add ( $ permission ) ; } } $ rolesPermissions = $ access -> rolesPermissions ( ) ; $ rolesTitles = $ access -> rolesTitles ( ) ; foreach ( $ rolesPermissions as $ roleName => $ permissions ) { $ role = $ auth -> getRole ( $ roleName ) ; if ( ! $ role ) { $ role = $ auth -> createRole ( $ roleName ) ; $ role -> description = $ rolesTitles [ $ roleName ] ; $ auth -> add ( $ role ) ; } $ oldPermissions = $ auth -> getPermissionsByRole ( $ roleName ) ; foreach ( $ permissions as $ permissionName ) { if ( ! isset ( $ oldPermissions [ $ permissionName ] ) ) { $ permission = $ auth -> getPermission ( $ permissionName ) ; $ auth -> addChild ( $ role , $ permission ) ; } } } }
init roles for extension class

@param $access AccessInterface
init roles for extension class