Introduce RoleForm#onRenameSuccess() to be able to overwrite it

This commit is contained in:
Alexander A. Klimov 2024-04-11 11:38:18 +02:00
parent d14a2f6958
commit 0a79dcef42

View File

@ -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
*