From 6b70f9b7fb27e387219ee8c03411032a0cb37723 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Mon, 20 Mar 2023 00:20:41 +0100 Subject: [PATCH] fix init check --- src/Backend.php | 10 +++++----- src/Config.php | 16 ++++++---------- src/Install.php | 13 ++++++------- src/Manage.php | 10 +++++----- src/Prepend.php | 10 +++++----- 5 files changed, 27 insertions(+), 32 deletions(-) diff --git a/src/Backend.php b/src/Backend.php index 7650641..8ab4859 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -24,16 +24,16 @@ class Backend extends dcNsProcess { public static function init(): bool { - if (defined('DC_CONTEXT_ADMIN')) { - self::$init = dcCore::app()->auth->isSuperAdmin() && version_compare(phpversion(), My::PHP_MIN, '>='); - } + static::$init = defined('DC_CONTEXT_ADMIN') + && dcCore::app()->auth?->isSuperAdmin() + && My::phpCompliant(); - return self::$init; + return static::$init; } public static function process(): bool { - if (!self::$init) { + if (!static::$init) { return false; } diff --git a/src/Config.php b/src/Config.php index 2550382..7c06103 100644 --- a/src/Config.php +++ b/src/Config.php @@ -35,20 +35,16 @@ class Config extends dcNsProcess { public static function init(): bool { - if (defined('DC_CONTEXT_ADMIN')) { - if (version_compare(phpversion(), My::PHP_MIN, '>=')) { - self::$init = true; - } else { - dcCore::app()->error->add(sprintf(__('%s required php >= %s'), My::id(), My::PHP_MIN)); - } - } + static::$init = defined('DC_CONTEXT_ADMIN') + && dcCore::app()->auth?->isSuperAdmin() + && My::phpCompliant(); - return self::$init; + return static::$init; } public static function process(): bool { - if (!self::$init) { + if (!static::$init) { return false; } @@ -80,7 +76,7 @@ class Config extends dcNsProcess public static function render(): void { - if (!self::$init) { + if (!static::$init) { return; } diff --git a/src/Install.php b/src/Install.php index b865cc1..292406d 100644 --- a/src/Install.php +++ b/src/Install.php @@ -22,17 +22,16 @@ class Install extends dcNsProcess { public static function init(): bool { - if (defined('DC_CONTEXT_ADMIN')) { - self::$init = version_compare(phpversion(), My::PHP_MIN, '>=') - && dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version')); - } + static::$init = defined('DC_CONTEXT_ADMIN') + && My::phpCompliant() + && dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version')); - return self::$init; + return static::$init; } public static function process(): bool { - if (!self::$init) { + if (!static::$init) { return false; } @@ -52,7 +51,7 @@ class Install extends dcNsProcess * * @return bool Upgrade done */ - public static function growUp() + private static function growUp() { $current = dcCore::app()->getVersion(My::id()); diff --git a/src/Manage.php b/src/Manage.php index a6e5a14..7136507 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -26,16 +26,16 @@ class Manage extends dcNsProcess { public static function init(): bool { - if (defined('DC_CONTEXT_ADMIN')) { - self::$init = dcCore::app()->auth->isSuperAdmin() && version_compare(phpversion(), My::PHP_MIN, '>='); - } + static::$init = defined('DC_CONTEXT_ADMIN') + && dcCore::app()->auth?->isSuperAdmin() + && My::phpCompliant(); - return self::$init; + return static::$init; } public static function process(): bool { - if (!self::$init) { + if (!static::$init) { return false; } diff --git a/src/Prepend.php b/src/Prepend.php index 42e2cc3..e039311 100644 --- a/src/Prepend.php +++ b/src/Prepend.php @@ -21,16 +21,16 @@ class Prepend extends dcNsProcess { public static function init(): bool { - if (defined('DC_CONTEXT_ADMIN')) { - self::$init = dcCore::app()->auth->isSuperAdmin(); - } + static::$init = defined('DC_CONTEXT_ADMIN') + && dcCore::app()->auth?->isSuperAdmin() + && My::phpCompliant(); - return self::$init; + return static::$init; } public static function process(): bool { - if (!self::$init) { + if (!static::$init) { return false; }