diff --git a/src/ActionDescriptor.php b/src/ActionDescriptor.php index e9b49cf..419ae39 100644 --- a/src/ActionDescriptor.php +++ b/src/ActionDescriptor.php @@ -22,6 +22,9 @@ class ActionDescriptor /** @var string $id The action ID */ public readonly string $id; + /** @var string $ns The namespace (for defined action) */ + public readonly string $ns; + /** @var string $query The generic message (used for self::values() management) */ public readonly string $select; @@ -40,6 +43,7 @@ class ActionDescriptor public function __construct(array $description) { $this->id = (string) ($description['id'] ?? 'undefined'); + $this->ns = (string) ($description['ns'] ?? ''); $this->select = (string) ($description['select'] ?? 'undefined'); $this->query = (string) ($description['query'] ?? 'undefined'); $this->success = (string) ($description['success'] ?? 'undefined'); @@ -55,6 +59,7 @@ class ActionDescriptor { return [ 'id' => $this->id, + 'ns' => $this->ns, 'select' => $this->select, 'query' => $this->query, 'success' => $this->success, diff --git a/src/Manage.php b/src/Manage.php index 08ef6a8..9c058db 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -80,11 +80,11 @@ class Manage extends dcNsProcess $done = []; foreach ($actions as $cleaner => $stack) { 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[] = $action['success']; + if (isset($_POST['action'][$cleaner]) && isset($_POST['action'][$cleaner][$action->id])) { + if ($uninstaller->execute($cleaner, $action->id, $_POST['action'][$cleaner][$action->id])) { + $done[] = $action->success; } else { - dcCore::app()->error->add($action['error']); + dcCore::app()->error->add($action->error); } } } @@ -140,8 +140,8 @@ class Manage extends dcNsProcess foreach ($uninstaller->getUserActions($define->getId()) as $cleaner => $stack) { foreach ($stack as $action) { $fields[] = (new Para())->items([ - (new Checkbox(['action[' . $cleaner . '][' . $action['action'] . ']', 'action_' . $cleaner . '_' . $action['action']], true))->value($action['ns']), - (new Label($action['query'], Label::OUTSIDE_LABEL_AFTER))->for('action_' . $cleaner . '_' . $action['action'])->class('classic'), + (new Checkbox(['action[' . $cleaner . '][' . $action->id . ']', 'action_' . $cleaner . '_' . $action->id], true))->value($action->ns), + (new Label($action->query, Label::OUTSIDE_LABEL_AFTER))->for('action_' . $cleaner . '_' . $action->id)->class('classic'), ]); } } diff --git a/src/Uninstaller.php b/src/Uninstaller.php index 8051fea..541f695 100644 --- a/src/Uninstaller.php +++ b/src/Uninstaller.php @@ -71,7 +71,7 @@ class Uninstaller * * Load modules resets previously loaded modules and actions. * - * @param array $modules List of modules Define + * @param array $modules List of modules Define * * @return Uninstaller Uninstaller instance */ @@ -271,13 +271,14 @@ class Uninstaller return; } // fill action properties - $this->actions[$group][$this->module->getId()][$cleaner][] = [ + $this->actions[$group][$this->module->getId()][$cleaner][] = new ActionDescriptor([ + 'id' => $action, 'ns' => $ns, - 'action' => $action, + 'select' => $this->cleaners->get($cleaner)->actions[$action]->select, '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