MDL-61875 core_component: new method to get full components list

This commit is contained in:
Jake Dallimore
2018-04-10 08:44:40 +08:00
parent 2bd2660751
commit 5749f8a4f7
2 changed files with 60 additions and 0 deletions
+34
View File
@@ -1244,4 +1244,38 @@ $cache = '.var_export($cache, true).';
}
}
}
/**
* Returns a list of frankenstyle component names and their paths, for all components (plugins and subsystems).
*
* E.g.
* [
* 'mod' => [
* 'mod_forum' => FORUM_PLUGIN_PATH,
* ...
* ],
* ...
* 'core' => [
* 'core_comment' => COMMENT_SUBSYSTEM_PATH,
* ...
* ]
* ]
*
* @return array an associative array of components and their corresponding paths.
*/
public static function get_component_list() : array {
$components = [];
// Get all plugins.
foreach (self::get_plugin_types() as $plugintype => $typedir) {
$components[$plugintype] = [];
foreach (self::get_plugin_list($plugintype) as $pluginname => $plugindir) {
$components[$plugintype][$plugintype . '_' . $pluginname] = $plugindir;
}
}
// Get all subsystems.
foreach (self::get_core_subsystems() as $subsystemname => $subsystempath) {
$components['core']['core_' . $subsystemname] = $subsystempath;
}
return $components;
}
}