From 707dff39817dec503ece4675fbf65df377ce6676 Mon Sep 17 00:00:00 2001 From: Benni Mack Date: Tue, 31 Mar 2020 11:47:36 +0200 Subject: [PATCH] [TASK] Add Typo3Version class This class is a backport of the v10 equivalent, it is added to ensure an easier upgrade path for v11 in the future, when the constants will get removed. Adding this class in TYPO3 v9 also helps to improve the release process when packaging. Resolves: #90907 Releases: 9.5 Change-Id: I43de23c9bf77cac1b18d0fc9891dfe620a569656 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64028 Reviewed-by: Oliver Klee Reviewed-by: Georg Ringer Reviewed-by: Markus Klein Reviewed-by: Andreas Fernandez Tested-by: TYPO3com Tested-by: Georg Ringer Tested-by: Markus Klein Tested-by: Andreas Fernandez --- .../core/Classes/Information/Typo3Version.php | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 typo3/sysext/core/Classes/Information/Typo3Version.php diff --git a/typo3/sysext/core/Classes/Information/Typo3Version.php b/typo3/sysext/core/Classes/Information/Typo3Version.php new file mode 100644 index 000000000000..4bfeda25b881 --- /dev/null +++ b/typo3/sysext/core/Classes/Information/Typo3Version.php @@ -0,0 +1,64 @@ +getVersion()); + } + if (!defined('TYPO3_branch')) { + define('TYPO3_branch', $this->getBranch()); + } + } + + public function getVersion(): string + { + return static::VERSION; + } + + public function getBranch(): string + { + return static::BRANCH; + } + + /** + * Get 'major version' of version, e.g., '7' from '7.3.0' + * + * @return int Major version, e.g., '7' + */ + public function getMajorVersion(): int + { + [$explodedVersion] = explode('.', static::VERSION); + return (int)$explodedVersion; + } + + public function __toString(): string + { + return $this->getVersion(); + } +}