mirror of
https://github.com/Mibew/mibew.git
synced 2025-03-13 06:34:08 +03:00
Add versions check to plugins
This commit is contained in:
parent
d68b0bdb0c
commit
2d702f5542
@ -133,13 +133,25 @@ class Manager
|
||||
$plugin_classname,
|
||||
'getDependencies',
|
||||
));
|
||||
foreach ($plugin_dependencies as $dependency) {
|
||||
foreach ($plugin_dependencies as $dependency => $required_version) {
|
||||
if (empty(self::$loadedPlugins[$dependency])) {
|
||||
$error_message = "Plugin '{$dependency}' was not loaded "
|
||||
. "yet, but exists in '{$plugin_name}' dependencies list!";
|
||||
trigger_error($error_message, E_USER_WARNING);
|
||||
continue 2;
|
||||
}
|
||||
|
||||
$dependency_version = call_user_func(array(
|
||||
self::$loadedPlugins[$dependency],
|
||||
'getVersion'
|
||||
));
|
||||
|
||||
if ($required_version !== $dependency_version) {
|
||||
$error_message = "Plugin '{$dependency}' has version "
|
||||
. "incompatible with '{$plugin_name}' requirements!";
|
||||
trigger_error($error_message, E_USER_WARNING);
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Add plugin to loading queue
|
||||
|
@ -60,8 +60,9 @@ interface PluginInterface
|
||||
/**
|
||||
* Returns list of plugin's dependencies.
|
||||
*
|
||||
* Each element in the list is a string with a plugin name. If plugin have
|
||||
* no dependencies an empty array should be returned.
|
||||
* 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
|
||||
* array should be returned.
|
||||
*
|
||||
* @return array List of plugin's dependencies.
|
||||
*/
|
||||
@ -78,6 +79,17 @@ interface PluginInterface
|
||||
*/
|
||||
public static function getInfo();
|
||||
|
||||
/**
|
||||
* Returns version of the plugin.
|
||||
*
|
||||
* Version ID should follow semantic versioning convention (see
|
||||
* {@link http://semver.org/} for details). It is used to check plugin's
|
||||
* dependences.
|
||||
*
|
||||
* @return string Plugin's version.
|
||||
*/
|
||||
public static function getVersion();
|
||||
|
||||
/**
|
||||
* Makes all actions that are needed to install the plugin.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user