From c21672138ee1bdbc32160b417011510b09d058b1 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Thu, 16 Mar 2023 23:56:25 +0100 Subject: [PATCH] add php min, require php >= 8.1 --- src/Backend.php | 4 +++- src/Config.php | 8 +++++++- src/My.php | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Backend.php b/src/Backend.php index 671a434..cb0c6d4 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -24,7 +24,9 @@ class Backend extends dcNsProcess { public static function init(): bool { - self::$init = defined('DC_CONTEXT_ADMIN'); + if (defined('DC_CONTEXT_ADMIN')) { + self::$init = dcCore::app()->auth->isSuperAdmin() && version_compare(phpversion(), My::PHP_MIN, '>='); + } return self::$init; } diff --git a/src/Config.php b/src/Config.php index 9b82e61..cee6a24 100644 --- a/src/Config.php +++ b/src/Config.php @@ -33,7 +33,13 @@ class Config extends dcNsProcess { public static function init(): bool { - self::$init = defined('DC_CONTEXT_ADMIN'); + 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)); + } + } return self::$init; } diff --git a/src/My.php b/src/My.php index b692a7f..9fa5c87 100644 --- a/src/My.php +++ b/src/My.php @@ -18,6 +18,9 @@ use dcCore; class My { + /** @var string Required php version */ + public const PHP_MIN = '8.1'; + /** @var array Excluded files */ public const EXCLUDED_FILES = [ '.',