/**
* 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;
}