Permalink
Browse files

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.
  • Loading branch information...
1 parent bfaed43 commit 7a46a55d004e28b75cfde1831873397da05db844 @mudrd8mz mudrd8mz committed Apr 11, 2013
Showing with 10 additions and 4 deletions.
  1. +10 −4 lib/pluginlib.php
View
@@ -221,12 +221,18 @@ public function get_parent_of_subplugin($subplugintype) {
/**
* 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;
}
/**

0 comments on commit 7a46a55

Please sign in to comment.