MDL-39087 Fix plugin_manager::plugin_name() implementation

This is not directly related to the issue. However, it turned out that
if this method was called on plugin_manager without loaded plugins, it
would throw an error. This new implementation uses cleaner access to the
plugininfo subclass.
This commit is contained in:
David Mudrák
2013-04-12 01:42:58 +02:00
parent bfaed43214
commit 7a46a55d00
+10 -4
View File
@@ -221,12 +221,18 @@ class plugin_manager {
/**
* Returns a localized name of a given plugin
*
* @param string $plugin name of the plugin, eg mod_workshop or auth_ldap
* @param string $component name of the plugin, eg mod_workshop or auth_ldap
* @return string
*/
public function plugin_name($plugin) {
list($type, $name) = normalize_component($plugin);
return $this->pluginsinfo[$type][$name]->displayname;
public function plugin_name($component) {
$pluginfo = $this->get_plugin_info($component);
if (is_null($pluginfo)) {
throw new moodle_exception('err_unknown_plugin', 'core_plugin', '', array('plugin' => $component));
}
return $pluginfo->displayname;
}
/**