Skip to content

Commit 143b03d

Browse files
authored
add function to get OpenMage version (#866)
OpenMage follows Semantic Versioning 2.0.0 Also preparation for the first 19.4.0 Release
1 parent 1e65616 commit 143b03d

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

app/Mage.php

+43
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,49 @@ public static function getVersionInfo()
178178
);
179179
}
180180

181+
/**
182+
* Gets the current OpenMage version string
183+
* @link https://openmage.github.io/supported-versions.html
184+
* @link https://semver.org/
185+
*
186+
* @return string
187+
*/
188+
public static function getOpenMageVersion()
189+
{
190+
$i = self::getOpenMageVersionInfo();
191+
$versionString = "{$i['major']}.{$i['minor']}.{$i['patch']}";
192+
if ( $i['stability'] || $i['number'] ) {
193+
$versionString .= "-";
194+
if ( $i['stability'] && $i['number'] ) {
195+
$versionString .= implode('.', [$i['stability'], $i['number']]);
196+
} else {
197+
$versionString .= implode('', [$i['stability'], $i['number']]);
198+
}
199+
}
200+
return trim(
201+
$versionString,
202+
'.-'
203+
);
204+
}
205+
206+
/**
207+
* Gets the detailed OpenMage version information
208+
* @link https://openmage.github.io/supported-versions.html
209+
* @link https://semver.org/
210+
*
211+
* @return array
212+
*/
213+
public static function getOpenMageVersionInfo()
214+
{
215+
return array(
216+
'major' => '19',
217+
'minor' => '4',
218+
'patch' => '0',
219+
'stability' => '', // beta,alpha,rc
220+
'number' => '', // 1,2,3,0.3.7,x.7.z.92 @see https://semver.org/#spec-item-9
221+
);
222+
}
223+
181224
/**
182225
* Get current Magento edition
183226
*

0 commit comments

Comments
 (0)