diff --git a/src/Backend.php b/src/Backend.php index 3f0ea31..67ce112 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -15,20 +15,18 @@ declare(strict_types=1); namespace Dotclear\Plugin\topWriter; use dcCore; -use dcNsProcess; +use Dotclear\Core\Process; -class Backend extends dcNsProcess +class Backend extends Process { public static function init(): bool { - static::$init = defined('DC_CONTEXT_ADMIN'); - - return static::$init; + return self::status(My::checkContext(My::BACKEND)); } public static function process(): bool { - if (!static::$init) { + if (!self::status()) { return false; } diff --git a/src/BackendBehaviors.php b/src/BackendBehaviors.php index 235e587..d2b4074 100644 --- a/src/BackendBehaviors.php +++ b/src/BackendBehaviors.php @@ -114,11 +114,6 @@ class BackendBehaviors public static function adminAfterDashboardOptionsUpdate(?string $user_id): void { - // nullsafe - if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->auth->user_prefs)) { - return; - } - dcCore::app()->auth->user_prefs->get('dashboard')->put( 'topWriterPostsItems', !empty($_POST['topWriterPostsItems']), @@ -154,11 +149,6 @@ class BackendBehaviors private static function setDefaultPref(): array { - // nullsafe - if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->auth->user_prefs)) { - return []; - } - if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterPostsItems')) { dcCore::app()->auth->user_prefs->get('dashboard')->put( 'topWriterPostsItems', diff --git a/src/Frontend.php b/src/Frontend.php index 6e10052..2a64b6b 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -15,20 +15,18 @@ declare(strict_types=1); namespace Dotclear\Plugin\topWriter; use dcCore; -use dcNsProcess; +use Dotclear\Core\Process; -class Frontend extends dcNsProcess +class Frontend extends Process { public static function init(): bool { - static::$init = true; - - return static::$init; + return self::status(My::checkContext(My::FRONTEND)); } public static function process(): bool { - if (!static::$init) { + if (!self::status()) { return false; } diff --git a/src/My.php b/src/My.php new file mode 100644 index 0000000..f1ae0e5 --- /dev/null +++ b/src/My.php @@ -0,0 +1,21 @@ +