From cae0b183b43a819c83ea393a4ff91aaa98df8a06 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sun, 16 Apr 2023 15:16:39 +0200 Subject: [PATCH] no need of these methods for now --- src/Uninstaller.php | 53 +++++++++++---------------------------------- 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/src/Uninstaller.php b/src/Uninstaller.php index c75db71..68e3620 100644 --- a/src/Uninstaller.php +++ b/src/Uninstaller.php @@ -29,9 +29,6 @@ class Uninstaller /** @var string The Uninstall class name */ public const UNINSTALL_CLASS_NAME = 'Uninstall'; - /** @var Uninstaller $uninstaller Uninstaller instance */ - private static $uninstaller; - /** @var Cleaners $cleaners The cleaners stack */ public readonly Cleaners $cleaners; @@ -47,6 +44,9 @@ class Uninstaller /** @var array List of registered actions */ private array $actions = ['user' => [], 'direct' => []]; + /** @var Uninstaller $uninstaller Uninstaller instance */ + private static $uninstaller; + /** * Constructor load cleaners. */ @@ -93,8 +93,11 @@ class Uninstaller $class = $module->get('namespace') . '\\' . self::UNINSTALL_CLASS_NAME; if ($module->getId() != My::id() && is_a($class, dcNsProcess::class, true)) { $this->modules[$module->getId()] = $this->module = $module; + // check class prerequiretics if ($class::init()) { + // if class process returns true if ($class::process()) { + // add custom action (served by class render method ) $this->renders[] = $module->getId(); } $this->module = null; @@ -109,40 +112,6 @@ class Uninstaller return $this; } - /** - * Get a module $id Define if it exists. - * - * @param string $id The module ID - * - * @return dcModuleDefine Module Define - */ - public function getModule(string $id): ?dcModuleDefine - { - return $this->modules[$id] ?? null; - } - - /** - * Get all modules Define. - * - * @return array Modules Define - */ - public function getModules(): array - { - return $this->modules; - } - - /** - * Check if the module $id exists. - * - * @param string $id Module ID - * - * @return boolean Success - */ - public function hasModule(string $id): bool - { - return isset($this->modules[$id]); - } - /** * Check if the module $id has action custom fields. * @@ -230,7 +199,7 @@ class Uninstaller { $output = ''; if ($this->hasRender($id)) { - $class = $this->getModule($id)?->get('namespace') . '\\' . self::UNINSTALL_CLASS_NAME; + $class = $this->modules[$id]->get('namespace') . '\\' . self::UNINSTALL_CLASS_NAME; ob_start(); @@ -258,9 +227,11 @@ class Uninstaller */ public function execute(string $cleaner, string $action, string $ns): bool { + // unknown cleaner/action or no ns if (!isset($this->cleaners->get($cleaner)->actions[$action]) || empty($ns)) { return false; } + $this->cleaners->execute($cleaner, $action, $ns); return true; @@ -277,8 +248,10 @@ class Uninstaller private function addAction(string $group, string $cleaner, string $action, string $ns): void { // no current module or no cleaner id or no ns or unknown cleaner action - if (null === $this->module || empty($cleaner) || empty($ns) - || !isset($this->cleaners->get($cleaner)->actions[$action]) + if (null === $this->module + || empty($cleaner) + || empty($ns) + || !isset($this->cleaners->get($cleaner)->actions[$action]) ) { return; }