diff --git a/src/Backend.php b/src/Backend.php index e9b4a52..5abe967 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -34,16 +34,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 da7df86..addab25 100644 --- a/src/Config.php +++ b/src/Config.php @@ -42,20 +42,16 @@ class Config extends dcNsProcess { public static function init(): bool { - if (defined('DC_CONTEXT_ADMIN')) { - if (version_compare(phpversion(), My::PHP_MIN, '>=')) { - self::$init = dcCore::app()->auth->isSuperAdmin(); - } 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; } @@ -86,7 +82,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 1201403..b76414b 100644 --- a/src/Install.php +++ b/src/Install.php @@ -40,17 +40,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; } diff --git a/src/Manage.php b/src/Manage.php index b5e2db8..eb6c2a6 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -50,18 +50,18 @@ 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(); - if (self::$init) { + if (static::$init) { self::$improve = new Core(); self::$type = self::getType(); self::$module = self::getModule(); self::$action = self::getAction(); } - return self::$init; + return static::$init; } private static function getType(): string @@ -166,7 +166,7 @@ class Manage extends dcNsProcess public static function process(): bool { - if (!self::$init) { + if (!static::$init) { return false; } @@ -217,7 +217,7 @@ class Manage extends dcNsProcess public static function render(): void { - if (!self::$init) { + if (!static::$init) { return; } diff --git a/src/My.php b/src/My.php index 51cfdb3..b7b4780 100644 --- a/src/My.php +++ b/src/My.php @@ -39,4 +39,12 @@ class My { return __((string) dcCore::app()->plugins->moduleInfo(self::id(), 'name')); } + + /** + * Check php version + */ + public static function phpCompliant(): bool + { + return version_compare(phpversion(), self::PHP_MIN, '>='); + } }