From e7ad6b0178e17da4ba405ecd8a855ebd98301aed Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 15 Apr 2023 18:12:11 +0200 Subject: [PATCH] give filled and translated action properties --- src/Backend.php | 4 ++-- src/Manage.php | 6 +++--- src/Uninstaller.php | 22 +++++++++++----------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Backend.php b/src/Backend.php index d284b04..b747884 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -59,9 +59,9 @@ class Backend extends dcNsProcess foreach ($uninstaller->getDirectActions($define->getId()) as $cleaner => $stack) { foreach ($stack as $action) { if ($uninstaller->execute($cleaner, $action['action'], $action['ns'])) { - $done[] = sprintf($action['success'], $action['ns']); + $done[] = $action['success']; } else { - dcCore::app()->error->add(sprintf($action['error'], $action['ns'])); + dcCore::app()->error->add($action['error']); } } } diff --git a/src/Manage.php b/src/Manage.php index 9fcefb2..3207a9c 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -82,9 +82,9 @@ class Manage extends dcNsProcess foreach ($stack as $action) { if (isset($_POST['action'][$cleaner]) && isset($_POST['action'][$cleaner][$action['action']])) { if ($uninstaller->execute($cleaner, $action['action'], $_POST['action'][$cleaner][$action['action']])) { - $done[] = sprintf($action['success'], $_POST['action'][$cleaner][$action['action']]); + $done[] = $action['success']; } else { - dcCore::app()->error->add(sprintf($action['error'], $_POST['action'][$cleaner][$action['action']])); + dcCore::app()->error->add($action['error']); } } } @@ -141,7 +141,7 @@ class Manage extends dcNsProcess foreach ($stack as $action) { $fields[] = (new Para())->items([ (new Checkbox(['action[' . $cleaner . '][' . $action['action'] . ']', 'action_' . $cleaner . '_' . $action['action']], true))->value($action['ns']), - (new Label(sprintf($action['query'], $action['ns']), Label::OUTSIDE_LABEL_AFTER))->for('action_' . $cleaner . '_' . $action['action'])->class('classic'), + (new Label($action['query'], Label::OUTSIDE_LABEL_AFTER))->for('action_' . $cleaner . '_' . $action['action'])->class('classic'), ]); } } diff --git a/src/Uninstaller.php b/src/Uninstaller.php index 9c1f9a8..44f1df3 100644 --- a/src/Uninstaller.php +++ b/src/Uninstaller.php @@ -262,22 +262,22 @@ class Uninstaller private function addAction(string $group, string $cleaner, string $action, string $ns): void { - if (!self::group($group) || null === $this->module) { - return; - } - if (empty($cleaner) || empty($ns)) { + // invalid group or no current module or no cleaner id or ns + if (!self::group($group) || null === $this->module || empty($cleaner) || empty($ns)) { return; } + // unknow cleaner action if (!isset($this->cleaners->get($cleaner)->actions[$action])) { return; } - $this->actions[$group][$this->module->getId()][$cleaner][] = array_merge( - [ - 'ns' => $ns, - 'action' => $action, - ], - $this->cleaners->get($cleaner)->actions[$action]->dump() - ); + // fill action properties + $this->actions[$group][$this->module->getId()][$cleaner][] = [ + 'ns' => $ns, + 'action' => $action, + 'query' => sprintf($this->cleaners->get($cleaner)->actions[$action]->query, $ns), + 'success' => sprintf($this->cleaners->get($cleaner)->actions[$action]->success, $ns), + 'error' => sprintf($this->cleaners->get($cleaner)->actions[$action]->error, $ns), + ]; } private function getActions(string $group, string $id): array