mirror of
https://github.com/Mibew/mibew.git
synced 2025-03-13 22:54:07 +03:00
Add versions check to plugins
This commit is contained in:
parent
d68b0bdb0c
commit
2d702f5542
@ -133,13 +133,25 @@ class Manager
|
|||||||
$plugin_classname,
|
$plugin_classname,
|
||||||
'getDependencies',
|
'getDependencies',
|
||||||
));
|
));
|
||||||
foreach ($plugin_dependencies as $dependency) {
|
foreach ($plugin_dependencies as $dependency => $required_version) {
|
||||||
if (empty(self::$loadedPlugins[$dependency])) {
|
if (empty(self::$loadedPlugins[$dependency])) {
|
||||||
$error_message = "Plugin '{$dependency}' was not loaded "
|
$error_message = "Plugin '{$dependency}' was not loaded "
|
||||||
. "yet, but exists in '{$plugin_name}' dependencies list!";
|
. "yet, but exists in '{$plugin_name}' dependencies list!";
|
||||||
trigger_error($error_message, E_USER_WARNING);
|
trigger_error($error_message, E_USER_WARNING);
|
||||||
continue 2;
|
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
|
// Add plugin to loading queue
|
||||||
|
@ -60,8 +60,9 @@ interface PluginInterface
|
|||||||
/**
|
/**
|
||||||
* Returns list of plugin's dependencies.
|
* Returns list of plugin's dependencies.
|
||||||
*
|
*
|
||||||
* Each element in the list is a string with a plugin name. If plugin have
|
* Each key in the array is a string with a plugin name. Each value is
|
||||||
* no dependencies an empty array should be returned.
|
* required plugin version. 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.
|
||||||
*/
|
*/
|
||||||
@ -78,6 +79,17 @@ interface PluginInterface
|
|||||||
*/
|
*/
|
||||||
public static function getInfo();
|
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.
|
* Makes all actions that are needed to install the plugin.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user