2
0
mirror of https://github.com/slawkens/myaac.git synced 2025-05-12 17:09:21 +02:00

* plugins require like composer: "ext-curl": >"5.0"

Allow require php extension with composer syntax: ext-name: version
This commit is contained in:
slawkens1 2018-02-05 21:52:54 +01:00
parent cfca37b09c
commit fc30e28e84
2 changed files with 17 additions and 4 deletions
plugins
system/libs

@ -11,6 +11,7 @@
"php_": ">5.4,<7.0", // support for defining versions like in composer (since 0.8)
"database": "21",
"php-ext": "curl", // php extension needs to be installed (since 0.8)
"ext-curl": ">5.0", // php extension with version specifiec (since 0.8)
"table": "accounts", // table need to exist in database (since 0.8)
"column": "players.online" // column need to exist in database (since 0.8)
},

@ -66,6 +66,8 @@ function is_sub_dir($path = NULL, $parent_folder = SITE_PATH) {
return FALSE;
}
use Composer\Semver\Semver;
class Plugins {
private static $warnings = array();
private static $error = null;
@ -126,7 +128,7 @@ class Plugins {
$myaac_satified = true;
if(isset($require['myaac_'])) {
$require_myaac = $require['myaac_'];
if(!Composer\Semver\Semver::satisfies(MYAAC_VERSION, $require_myaac)) {
if(!Semver::satisfies(MYAAC_VERSION, $require_myaac)) {
$myaac_satified = false;
}
}
@ -145,7 +147,7 @@ class Plugins {
$php_satified = true;
if(isset($require['php_'])) {
$require_php = $require['php_'];
if(!Composer\Semver\Semver::satisfies(phpversion(), $require_php)) {
if(!Semver::satisfies(phpversion(), $require_php)) {
$php_satified = false;
}
}
@ -164,7 +166,7 @@ class Plugins {
$database_satified = true;
if(isset($require['database_'])) {
$require_database = $require['database_'];
if(!Composer\Semver\Semver::satisfies(DATABASE_VERSION, $require_database)) {
if(!Semver::satisfies(DATABASE_VERSION, $require_database)) {
$database_satified = false;
}
}
@ -211,6 +213,16 @@ class Plugins {
}
}
}
else if(strpos($req, 'ext-') !== false) {
$tmp = explode('-', $req);
if(count($tmp) == 2) {
if(!extension_loaded($tmp[1]) || !Semver::satisfies(phpversion($tmp[1]), $version)) {
self::$error = "This plugin requires php extension: " . $tmp[1] . ", version " . $version . " to be installed.";
$continue = false;
break;
}
}
}
else if(!self::is_installed($req, $version)) {
self::$error = "This plugin requires another plugin to run correctly. The another plugin is: " . $req . ", with version " . $version . ".";
$continue = false;
@ -361,7 +373,7 @@ class Plugins {
return false;
}
return Composer\Semver\Semver::satisfies($plugin_info['version'], $version);
return Semver::satisfies($plugin_info['version'], $version);
}
public static function getWarnings() {