add plugin Uninstaller features

2.28
Jean-Christian Paul Denis 2023-04-22 15:33:01 +02:00
parent b54e2df846
commit 782b60a505
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
1 changed files with 42 additions and 72 deletions

View File

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