use ActionDescriptor for defined actions
This commit is contained in:
parent
8720c67a9c
commit
b7107bdf3d
@ -22,6 +22,9 @@ class ActionDescriptor
|
|||||||
/** @var string $id The action ID */
|
/** @var string $id The action ID */
|
||||||
public readonly string $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) */
|
/** @var string $query The generic message (used for self::values() management) */
|
||||||
public readonly string $select;
|
public readonly string $select;
|
||||||
|
|
||||||
@ -40,6 +43,7 @@ class ActionDescriptor
|
|||||||
public function __construct(array $description)
|
public function __construct(array $description)
|
||||||
{
|
{
|
||||||
$this->id = (string) ($description['id'] ?? 'undefined');
|
$this->id = (string) ($description['id'] ?? 'undefined');
|
||||||
|
$this->ns = (string) ($description['ns'] ?? '');
|
||||||
$this->select = (string) ($description['select'] ?? 'undefined');
|
$this->select = (string) ($description['select'] ?? 'undefined');
|
||||||
$this->query = (string) ($description['query'] ?? 'undefined');
|
$this->query = (string) ($description['query'] ?? 'undefined');
|
||||||
$this->success = (string) ($description['success'] ?? 'undefined');
|
$this->success = (string) ($description['success'] ?? 'undefined');
|
||||||
@ -55,6 +59,7 @@ class ActionDescriptor
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
|
'ns' => $this->ns,
|
||||||
'select' => $this->select,
|
'select' => $this->select,
|
||||||
'query' => $this->query,
|
'query' => $this->query,
|
||||||
'success' => $this->success,
|
'success' => $this->success,
|
||||||
|
@ -80,11 +80,11 @@ class Manage extends dcNsProcess
|
|||||||
$done = [];
|
$done = [];
|
||||||
foreach ($actions as $cleaner => $stack) {
|
foreach ($actions as $cleaner => $stack) {
|
||||||
foreach ($stack as $action) {
|
foreach ($stack as $action) {
|
||||||
if (isset($_POST['action'][$cleaner]) && isset($_POST['action'][$cleaner][$action['action']])) {
|
if (isset($_POST['action'][$cleaner]) && isset($_POST['action'][$cleaner][$action->id])) {
|
||||||
if ($uninstaller->execute($cleaner, $action['action'], $_POST['action'][$cleaner][$action['action']])) {
|
if ($uninstaller->execute($cleaner, $action->id, $_POST['action'][$cleaner][$action->id])) {
|
||||||
$done[] = $action['success'];
|
$done[] = $action->success;
|
||||||
} else {
|
} 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 ($uninstaller->getUserActions($define->getId()) as $cleaner => $stack) {
|
||||||
foreach ($stack as $action) {
|
foreach ($stack as $action) {
|
||||||
$fields[] = (new Para())->items([
|
$fields[] = (new Para())->items([
|
||||||
(new Checkbox(['action[' . $cleaner . '][' . $action['action'] . ']', 'action_' . $cleaner . '_' . $action['action']], true))->value($action['ns']),
|
(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['action'])->class('classic'),
|
(new Label($action->query, Label::OUTSIDE_LABEL_AFTER))->for('action_' . $cleaner . '_' . $action->id)->class('classic'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ class Uninstaller
|
|||||||
*
|
*
|
||||||
* Load modules resets previously loaded modules and actions.
|
* Load modules resets previously loaded modules and actions.
|
||||||
*
|
*
|
||||||
* @param array $modules List of modules Define
|
* @param array<int,dcModuleDefine> $modules List of modules Define
|
||||||
*
|
*
|
||||||
* @return Uninstaller Uninstaller instance
|
* @return Uninstaller Uninstaller instance
|
||||||
*/
|
*/
|
||||||
@ -271,13 +271,14 @@ class Uninstaller
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// fill action properties
|
// fill action properties
|
||||||
$this->actions[$group][$this->module->getId()][$cleaner][] = [
|
$this->actions[$group][$this->module->getId()][$cleaner][] = new ActionDescriptor([
|
||||||
|
'id' => $action,
|
||||||
'ns' => $ns,
|
'ns' => $ns,
|
||||||
'action' => $action,
|
'select' => $this->cleaners->get($cleaner)->actions[$action]->select,
|
||||||
'query' => sprintf($this->cleaners->get($cleaner)->actions[$action]->query, $ns),
|
'query' => sprintf($this->cleaners->get($cleaner)->actions[$action]->query, $ns),
|
||||||
'success' => sprintf($this->cleaners->get($cleaner)->actions[$action]->success, $ns),
|
'success' => sprintf($this->cleaners->get($cleaner)->actions[$action]->success, $ns),
|
||||||
'error' => sprintf($this->cleaners->get($cleaner)->actions[$action]->error, $ns),
|
'error' => sprintf($this->cleaners->get($cleaner)->actions[$action]->error, $ns),
|
||||||
];
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getActions(string $group, string $id): array
|
private function getActions(string $group, string $id): array
|
||||||
|
Loading…
Reference in New Issue
Block a user