Loading src/StoragePermissions.php +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ class StoragePermissions { "delete own $type_id storage entities" => [ 'title' => $this->t('Delete own %type_name Storage entities', $type_params), ], "delete any $type_id entities" => [ "delete any $type_id storage entities" => [ 'title' => $this->t('Delete any %type_name Storage entities', $type_params), 'restrict access' => TRUE, ], Loading storage.install +30 −0 Original line number Diff line number Diff line Loading @@ -51,3 +51,33 @@ function storage_update_8101(&$sandbox) { } return t('Update completed, no changes were made.'); } /** * Convert "Delete any %type entities" to "Delete any %type storage entities". * * The previous update did not convert this permission to the new format. * Export your configuration after performing this update. */ function storage_update_8102() { $config_changed = FALSE; /** @var \Drupal\user\RoleInterface $role */ foreach (\Drupal::entityTypeManager()->getStorage('user_role')->loadMultiple() as $role) { $permissions_changed = FALSE; foreach (\Drupal::entityTypeManager()->getStorage('storage_type')->loadMultiple() as $storage_type) { $type_id = $storage_type->id(); if (!$role->isAdmin() && $role->hasPermission("delete any $type_id entities")) { $role->revokePermission("delete any $type_id entities"); $role->grantPermission("delete any $type_id storage entities"); $permissions_changed = TRUE; $config_changed = TRUE; } } if ($permissions_changed) { $role->trustData()->save(); } } if ($config_changed) { return t('Permission conversion completed. Export your configuration to synchronize the applied changes.'); } return t('Update completed, no changes were made.'); } Loading
src/StoragePermissions.php +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ class StoragePermissions { "delete own $type_id storage entities" => [ 'title' => $this->t('Delete own %type_name Storage entities', $type_params), ], "delete any $type_id entities" => [ "delete any $type_id storage entities" => [ 'title' => $this->t('Delete any %type_name Storage entities', $type_params), 'restrict access' => TRUE, ], Loading
storage.install +30 −0 Original line number Diff line number Diff line Loading @@ -51,3 +51,33 @@ function storage_update_8101(&$sandbox) { } return t('Update completed, no changes were made.'); } /** * Convert "Delete any %type entities" to "Delete any %type storage entities". * * The previous update did not convert this permission to the new format. * Export your configuration after performing this update. */ function storage_update_8102() { $config_changed = FALSE; /** @var \Drupal\user\RoleInterface $role */ foreach (\Drupal::entityTypeManager()->getStorage('user_role')->loadMultiple() as $role) { $permissions_changed = FALSE; foreach (\Drupal::entityTypeManager()->getStorage('storage_type')->loadMultiple() as $storage_type) { $type_id = $storage_type->id(); if (!$role->isAdmin() && $role->hasPermission("delete any $type_id entities")) { $role->revokePermission("delete any $type_id entities"); $role->grantPermission("delete any $type_id storage entities"); $permissions_changed = TRUE; $config_changed = TRUE; } } if ($permissions_changed) { $role->trustData()->save(); } } if ($config_changed) { return t('Permission conversion completed. Export your configuration to synchronize the applied changes.'); } return t('Update completed, no changes were made.'); }