[RCD] Retrieving plugin instance

Marcus Don mdon at names.co.uk
Thu Apr 5 16:13:49 CEST 2012


Hi

I'm currently updating an installation of Roundcube based on RC 0.5.4 (!) to use RC 0.7.2. One difference I have found is that the function rcube_plugin_api:get_plugin() no longer exists. 

According to our local SVN history, this function was added when we merged with RC 0.4.2. However, I can't find this anywhere in the repository at trac.roundcube.net, so I'm beginning to wonder whether it was actually a custom method added by one of my colleagues (who must have forgotten to document it).

Please can you tell me whether this function (shown below) has ever existed in a previous release of Roundcube, and whether there is a better, supported way to retrieve an existing instance of a plugin (ie so plugins can talk to each other without creating duplicate instances)? If not, I'm happy to create a ticket and submit a patch.

Thanks

Marcus


  /**
   * Retrieves a plugin by it's class name.
   *
   * If $plugin_class is not set, return all plugins
   *
   * @param string $plugin_class Plugin's class name.
   *
   * @return rcube_plugin|array
   */
  public  function get_plugin($plugin_class = '') {
          if (!empty($plugin_class)) {
                  foreach ($this->plugins as $plugin) {
                          if (is_a($plugin, $plugin_class)) {
                                  return $plugin;
                          }
                  }
                  return null;
          }

          return $this->plugins;
  }



More information about the dev mailing list