mirror of
https://github.com/Mibew/mibew.git
synced 2025-04-10 09:50:12 +03:00
Use versions range in plugin dependencies
This commit is contained in:
parent
2d702f5542
commit
c205c9ff94
@ -25,7 +25,8 @@
|
|||||||
"symfony/yaml": "2.5.*",
|
"symfony/yaml": "2.5.*",
|
||||||
"symfony/translation": "2.5.*",
|
"symfony/translation": "2.5.*",
|
||||||
"tedivm/stash": "0.12.*",
|
"tedivm/stash": "0.12.*",
|
||||||
"canteen/html5": "1.1.*"
|
"canteen/html5": "1.1.*",
|
||||||
|
"vierbergenlars/php-semver": "3.0.*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"squizlabs/php_codesniffer": "1.*"
|
"squizlabs/php_codesniffer": "1.*"
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
namespace Mibew\Plugin;
|
namespace Mibew\Plugin;
|
||||||
|
|
||||||
|
use vierbergenlars\SemVer\version as Version;
|
||||||
|
use vierbergenlars\SemVer\expression as VersionExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage plugins
|
* Manage plugins
|
||||||
*/
|
*/
|
||||||
@ -141,12 +144,13 @@ class Manager
|
|||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$version_constrain = new VersionExpression($required_version);
|
||||||
$dependency_version = call_user_func(array(
|
$dependency_version = call_user_func(array(
|
||||||
self::$loadedPlugins[$dependency],
|
self::$loadedPlugins[$dependency],
|
||||||
'getVersion'
|
'getVersion'
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($required_version !== $dependency_version) {
|
if (!$version_constrain->satisfiedBy(new Version($dependency_version))) {
|
||||||
$error_message = "Plugin '{$dependency}' has version "
|
$error_message = "Plugin '{$dependency}' has version "
|
||||||
. "incompatible with '{$plugin_name}' requirements!";
|
. "incompatible with '{$plugin_name}' requirements!";
|
||||||
trigger_error($error_message, E_USER_WARNING);
|
trigger_error($error_message, E_USER_WARNING);
|
||||||
|
@ -61,8 +61,22 @@ interface PluginInterface
|
|||||||
* Returns list of plugin's dependencies.
|
* Returns list of plugin's dependencies.
|
||||||
*
|
*
|
||||||
* Each key in the array is a string with a plugin name. Each value is
|
* Each key in the array is a string with a plugin name. Each value is
|
||||||
* required plugin version. If the plugin have no dependencies an empty
|
* plugin version constrain. A constrain can be in one of the following
|
||||||
* array should be returned.
|
* formats:
|
||||||
|
* - "1.2.3": exact version number;
|
||||||
|
* - ">1.2.3": grater than a specific version;
|
||||||
|
* - ">=1.2.3": greater than a specific version or equal to it;
|
||||||
|
* - "<1.2.3": less than a specific version;
|
||||||
|
* - "<=1.2.3": less than a specific version or equal to it;
|
||||||
|
* - "1.2.3 - 2.3.4": equals to ">=1.2.3 <=2.3.4";
|
||||||
|
* - "~1.2.3": equivalent for ">=1.2.3 <1.3.0";
|
||||||
|
* - "~1.2": equivalent for ">=1.2.0 <2.0.0";
|
||||||
|
* - "^1.2.3" equivalent for ">=1.2.3 <2.0.0";
|
||||||
|
* - "^0.1.2" equivalent for ">=0.1.2 <0.2.0";
|
||||||
|
* - "1.2.x": equivalent for ">=1.2.0 <2.0.0";
|
||||||
|
* - "1.x": equivalent for ">=1.0.0 <2.0.0";
|
||||||
|
*
|
||||||
|
* If the plugin have no dependencies an empty array should be returned.
|
||||||
*
|
*
|
||||||
* @return array List of plugin's dependencies.
|
* @return array List of plugin's dependencies.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user