1
|
|
|
<?php |
2
|
|
|
namespace Gilbertsoft\Lib\Utility; |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file is part of the "GS Library" Extension for TYPO3 CMS. |
6
|
|
|
* |
7
|
|
|
* Copyright (C) 2017 by Gilbertsoft (gilbertsoft.org) |
8
|
|
|
* |
9
|
|
|
* This program is free software: you can redistribute it and/or modify |
10
|
|
|
* it under the terms of the GNU General Public License as published by |
11
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
12
|
|
|
* (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* For the full license information, please read the LICENSE file that |
20
|
|
|
* was distributed with this source code. |
21
|
|
|
* |
22
|
|
|
* The TYPO3 project - inspiring people to share! |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Use declarations |
27
|
|
|
*/ |
28
|
|
|
use TYPO3\CMS\Core\Utility\VersionNumberUtility; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Utility class to handle version comparings. |
32
|
|
|
* |
33
|
|
|
* USE: |
34
|
|
|
* The class is intended to be used without creating an instance of it. |
35
|
|
|
* So: Do not instantiate - call functions with "\Gilbertsoft\Lib\Utility\VersionUtility::" prefixed the function name. |
36
|
|
|
* So use \Gilbertsoft\Lib\Utility\VersionUtility::[method-name] to refer to the functions, eg. '\Gilbertsoft\Lib\Utility\VersionUtility::isVersion()' |
37
|
|
|
*/ |
38
|
|
|
class Typo3Version |
39
|
|
|
{ |
40
|
|
|
/** |
41
|
|
|
* @var integer $version |
42
|
|
|
*/ |
43
|
|
|
private static $version = null; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Returns the TYPO3 version as integer |
47
|
|
|
* |
48
|
|
|
* @return integer |
49
|
|
|
* @api |
50
|
|
|
*/ |
51
|
|
|
protected static function getBranch() |
52
|
|
|
{ |
53
|
|
|
if (is_null(self::$version)) { |
54
|
|
|
self::$version = VersionNumberUtility::convertVersionNumberToInteger(TYPO3_branch); |
55
|
|
|
} |
56
|
|
|
return self::$version; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Returns TRUE if the current TYPO3 version (or compatibility version) is compatible to the input version |
61
|
|
|
* Notice that this function compares branches, not versions (4.0.1 would be > 4.0.0 although they use the same compat_version) |
62
|
|
|
* |
63
|
|
|
* @param string $branchNumberStr Minimum branch number required (format x.y / e.g. "4.0" NOT "4.0.0"!) |
64
|
|
|
* @return bool Returns TRUE if this setup is compatible with the provided version number |
65
|
|
|
* @todo Still needs a function to convert versions to branches |
66
|
|
|
*/ |
67
|
|
|
public static function isVersion($branchNumberStr) |
68
|
|
|
{ |
69
|
|
|
return (self::getBranch() == VersionNumberUtility::convertVersionNumberToInteger($branchNumberStr)); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Returns TRUE if the current TYPO3 version (or compatibility version) is compatible to the input version |
74
|
|
|
* Notice that this function compares branches, not versions (4.0.1 would be > 4.0.0 although they use the same compat_version) |
75
|
|
|
* |
76
|
|
|
* @param string $branchNumberStr Minimum branch number required (format x.y / e.g. "4.0" NOT "4.0.0"!) |
77
|
|
|
* @return bool Returns TRUE if this setup is compatible with the provided version number |
78
|
|
|
* @todo Still needs a function to convert versions to branches |
79
|
|
|
*/ |
80
|
|
|
public static function isCompatVersion($branchNumberStr) |
81
|
|
|
{ |
82
|
|
|
return (self::getBranch() >= VersionNumberUtility::convertVersionNumberToInteger($branchNumberStr)); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|