function cloudflare_update_8002 in CloudFlare 8
Grants the 'administer cloudflare' permission to eligible roles.
File
- ./
cloudflare.install, line 55 - Install, update, and uninstall functions for the CloudFlare module.
Code
function cloudflare_update_8002(&$sandbox) {
try {
/* @var $user_role_storage \Drupal\user\RoleStorageInterface */
$user_role_storage = \Drupal::entityTypeManager()
->getStorage('user_role');
/* @var $roles array|\Drupal\user\RoleInterface[] */
$roles = $user_role_storage
->loadMultiple();
foreach ($roles as $role) {
if ($role
->hasPermission('access administration pages')) {
$role
->grantPermission('administer cloudflare')
->save();
}
}
} catch (EntityStorageException $e) {
throw new UpdateException('Update 8002 failed with the following: ' . $e
->getMessage(), $e
->getCode(), $e);
} catch (InvalidPluginDefinitionException $e) {
throw new UpdateException('Update 8002 failed with the following: ' . $e
->getMessage(), $e
->getCode(), $e);
} catch (PluginNotFoundException $e) {
throw new UpdateException('Update 8002 failed with the following: ' . $e
->getMessage(), $e
->getCode(), $e);
}
}