You are here

function workbench_access_post_update_convert_role_storage_keys in Workbench Access 8

Convert role storage.

File

./workbench_access.post_update.php, line 79
Contains post update hooks.

Code

function workbench_access_post_update_convert_role_storage_keys() {
  foreach (\Drupal::entityTypeManager()
    ->getStorage('user_role')
    ->loadMultiple() as $rid => $role) {
    $prefix = 'workbench_access_roles_';
    $old_key = $prefix . $rid;
    $new_key = $prefix . 'default__' . $rid;
    $state = \Drupal::state();
    if ($existing = $state
      ->get($old_key, FALSE)) {
      $state
        ->set($new_key, $existing);
      $state
        ->delete($old_key);
    }
  }
}