add plugin Uninstaller features

This commit is contained in:
Jean-Christian Denis 2023-04-23 23:59:21 +02:00
parent caa46c59a2
commit 0cc8c5b326
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951

View file

@ -14,89 +14,59 @@ declare(strict_types=1);
namespace Dotclear\Plugin\translater; namespace Dotclear\Plugin\translater;
class Uninstall use dcCore;
{ use dcNsProcess;
protected static bool $init = false; use Dotclear\Plugin\Uninstaller\Uninstaller;
class Uninstall extends dcNsProcess
{
public static function init(): bool public static function init(): bool
{ {
self::$init = defined('DC_RC_PATH'); static::$init = defined('DC_CONTEXT_ADMIN');
return self::$init; return static::$init;
} }
public static function process($uninstaller): ?bool public static function process(): bool
{ {
if (!self::$init) { if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
return false; return false;
} }
$uninstaller->addUserAction( Uninstaller::instance()
/* type */ ->addUserAction(
'settings', 'settings',
/* action */ 'delete_all',
'delete_all', My::id()
/* ns */ )
My::id(), ->addUserAction(
/* description */ 'plugins',
__('delete all settings') 'delete',
); My::id()
)
->addUserAction(
'versions',
'delete',
My::id()
)
->addDirectAction(
'settings',
'delete_all',
My::id()
)
->addDirectAction(
'plugins',
'delete',
My::id()
)
->addDirectAction(
'versions',
'delete',
My::id()
)
;
$uninstaller->addUserAction( // no custom action
/* type */ return false;
'plugins',
/* action */
'delete',
/* ns */
My::id(),
/* description */
__('delete plugin files')
);
$uninstaller->addUserAction(
/* type */
'versions',
/* action */
'delete',
/* ns */
My::id(),
/* description */
__('delete the version number')
);
$uninstaller->addDirectAction(
/* type */
'settings',
/* action */
'delete_all',
/* ns */
My::id(),
/* description */
sprintf(__('delete all %s settings'), My::id())
);
$uninstaller->addDirectAction(
/* type */
'plugins',
/* action */
'delete',
/* ns */
My::id(),
/* description */
sprintf(__('delete %s plugin files'), My::id())
);
$uninstaller->addDirectAction(
/* type */
'versions',
/* action */
'delete',
/* ns */
My::id(),
/* description */
sprintf(__('delete %s version number'), My::id())
);
return true;
} }
} }