From 12851f6c77eba59b613ed7940d289a24a81315ea Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Thu, 20 Apr 2023 22:11:39 +0200 Subject: [PATCH] use plugin Uninstaller --- src/Uninstall.php | 114 +++++++++++++++++----------------------------- 1 file changed, 42 insertions(+), 72 deletions(-) diff --git a/src/Uninstall.php b/src/Uninstall.php index 65fcc71..9e768cf 100644 --- a/src/Uninstall.php +++ b/src/Uninstall.php @@ -14,89 +14,59 @@ declare(strict_types=1); namespace Dotclear\Plugin\dcFilterDuplicate; -class Uninstall -{ - protected static $init = false; +use dcCore; +use dcNsProcess; +use Dotclear\Plugin\Uninstaller\Uninstaller; +class Uninstall extends dcNsProcess +{ public static function init(): bool { - static::$init = defined('DC_RC_PATH'); + static::$init = defined('DC_CONTEXT_ADMIN'); return static::$init; } - public static function process($uninstaller): ?bool + public static function process(): bool { - if (!static::$init) { + if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) { return false; } - $uninstaller->addUserAction( - /* type */ - 'settings', - /* action */ - 'delete_all', - /* ns */ - My::id(), - /* desc */ - __('delete all settings') - ); + Uninstaller::instance() + ->addUserAction( + 'settings', + 'delete_all', + My::id() + ) + ->addUserAction( + 'plugins', + 'delete', + My::id() + ) + ->addUserAction( + 'versions', + 'delete', + My::id() + ) + ->addDirectAction( + 'settings', + 'delete_all', + My::id() + ) + ->addDirectAction( + 'versions', + 'delete', + My::id() + ) + ->addDirectAction( + 'plugins', + 'delete', + My::id() + ) + ; - $uninstaller->addUserAction( - /* type */ - 'plugins', - /* action */ - 'delete', - /* ns */ - My::id(), - /* desc */ - __('delete plugin files') - ); - - $uninstaller->addUserAction( - /* type */ - 'versions', - /* action */ - 'delete', - /* ns */ - My::id(), - /* desc */ - __('delete the version number') - ); - - $uninstaller->addDirectAction( - /* type */ - 'settings', - /* action */ - 'delete_all', - /* ns */ - My::id(), - /* desc */ - sprintf(__('delete all %s settings'), My::id()) - ); - - $uninstaller->addDirectAction( - /* type */ - 'versions', - /* action */ - 'delete', - /* ns */ - My::id(), - /* desc */ - sprintf(__('delete %s version number'), My::id()) - ); - - $uninstaller->addDirectAction( - /* type */ - 'plugins', - /* action */ - 'delete', - /* ns */ - My::id(), - /* desc */ - sprintf(__('delete %s plugin files'), My::id()) - ); - - return true; + // no custom action + return false; } }