From 0a79dcef421649e7e0a3c02c8fe0fd29c10c424a Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 11 Apr 2024 11:38:18 +0200 Subject: [PATCH] Introduce RoleForm#onRenameSuccess() to be able to overwrite it --- application/forms/Security/RoleForm.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index 58387f7aa..5dd78bc33 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -511,11 +511,7 @@ class RoleForm extends RepositoryForm } if ($this->getIdentifier() && ($newName = $this->getValue('name')) !== $this->getIdentifier()) { - $this->repository->update( - $this->getBaseTable(), - ['parent' => $newName], - Filter::where('parent', $this->getIdentifier()) - ); + $this->onRenameSuccess($this->getIdentifier(), $newName); } if (ConfigFormEventsHook::runOnSuccess($this) === false) { @@ -526,6 +522,17 @@ class RoleForm extends RepositoryForm } } + /** + * Update child roles of role $oldName, set their parent to $newName + * + * @param string $oldName + * @param string $newName + */ + protected function onRenameSuccess(string $oldName, ?string $newName): void + { + $this->repository->update($this->getBaseTable(), ['parent' => $newName], Filter::where('parent', $oldName)); + } + /** * Collect permissions and restrictions provided by Icinga Web 2 and modules *