function thunder_update_8110 in Thunder 8.2
Adjust access permissions related to "responsive_preview" module.
File
- ./
thunder.install, line 628 - Install, update and uninstall functions for the thunder installation profile.
Code
function thunder_update_8110() {
/** @var \Drupal\update_helper\UpdateLogger $updateLogger */
$updateLogger = \Drupal::service('update_helper.logger');
// Granting permissions only for "editor" and "seo" user roles.
$roles = Role::loadMultiple([
'editor',
'seo',
]);
foreach ($roles as $role) {
if ($role
->hasPermission('access content')) {
try {
$role
->grantPermission('access responsive preview');
$role
->save();
$updateLogger
->info(t('Permission for accessing responsive preview is granted for @user_role user role.', [
'@user_role' => $role
->id(),
]));
} catch (EntityStorageException $storageException) {
$updateLogger
->warning(t('Unable to change permissions for @user_role user role.', [
'@user_role' => $role
->id(),
]));
}
}
else {
$updateLogger
->info(t('Skipping @user_role user role, because of non-sufficient permissions.', [
'@user_role' => $role
->id(),
]));
}
}
// Output logged result of update hook execution.
return $updateLogger
->output();
}