Back to PluginHelper class

Method getPlugin

public static mixed
getPlugin
(mixed $type, mixed $plugin = null)
Get the plugin data of a specific type if no specific plugin is specified otherwise only the specific plugin data is returned.
Parameters
  • string $type The plugin type, relates to the subdirectory in the plugins directory.
  • string $plugin The plugin name.
Returns
  • mixed An array of plugin data objects, or a plugin data object.
Since
  • 1.5
Class: PluginHelper
Project: Joomla

Method getPlugin - Source code

/**
 * Get the plugin data of a specific type if no specific plugin is specified
 * otherwise only the specific plugin data is returned.
 *
 * @param   string  $type    The plugin type, relates to the subdirectory in the plugins directory.
 * @param   string  $plugin  The plugin name.
 *
 * @return  mixed  An array of plugin data objects, or a plugin data object.
 *
 * @since   1.5
 */
public static function getPlugin($type, $plugin = null)
{
    $result = [];
    $plugins = static::load();
    // Find the correct plugin(s) to return.
    if (!$plugin) {
        foreach ($plugins as $p) {
            // Is this the right plugin?
            if ($p->type === $type) {
                $result[] = $p;
            }
        }
    } else {
        foreach ($plugins as $p) {
            // Is this plugin in the right group?
            if ($p->type === $type && $p->name === $plugin) {
                $result = $p;
                break;
            }
        }
    }
    return $result;
}