MDL-32329 new plugininfo_base::is_core_dependency_satisfied() method
The method's logic was previously implemented in all_plugins_ok() but we will need to call it separately. Also make the code cleaner.
This commit is contained in:
+17
-1
@@ -296,7 +296,7 @@ class plugin_manager {
|
||||
foreach ($this->get_plugins() as $type => $plugins) {
|
||||
foreach ($plugins as $plugin) {
|
||||
|
||||
if (!empty($plugin->versionrequires) && $plugin->versionrequires > $moodleversion) {
|
||||
if (!$plugin->is_core_dependency_satisfied($moodleversion)) {
|
||||
$return = false;
|
||||
$failedplugins[] = $plugin->component;
|
||||
}
|
||||
@@ -1620,6 +1620,22 @@ abstract class plugininfo_base {
|
||||
return $this->source === plugin_manager::PLUGIN_SOURCE_STANDARD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the the given Moodle version is enough to run this plugin
|
||||
*
|
||||
* @param string|int|double $moodleversion
|
||||
* @return bool
|
||||
*/
|
||||
public function is_core_dependency_satisfied($moodleversion) {
|
||||
|
||||
if (empty($this->versionrequires)) {
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return (double)$this->versionrequires <= (double)$moodleversion;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the status of the plugin
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user