protected function makePluginClass($pluginName)
{
$pluginFileName = sprintf("%s/%s.php", $pluginName, $pluginName);
$pluginClassName = $pluginName;
if (!$this->isValidPluginName($pluginName)) {
throw new \Exception(sprintf("The plugin filename '%s' is not a valid plugin name", $pluginFileName));
}
$path = self::getPluginsDirectory() . $pluginFileName;
if (!file_exists($path)) {
// Create the smallest minimal Piwik Plugin
// Eg. Used for Morpheus default theme which does not have a Morpheus.php file
return new Plugin($pluginName);
}
require_once $path;
$namespacedClass = $this->getClassNamePlugin($pluginName);
if (!class_exists($namespacedClass, false)) {
throw new \Exception("The class {$pluginClassName} couldn't be found in the file '{$path}'");
}
$newPlugin = new $namespacedClass();
if (!$newPlugin instanceof Plugin) {
throw new \Exception("The plugin {$pluginClassName} in the file {$path} must inherit from Plugin.");
}
return $newPlugin;
}