/**
* Constructor.
*
* @param string|bool $pluginName A plugin name to force. If not supplied, it is set
* to the last part of the class name.
* @throws \Exception If plugin metadata is defined in both the getInformation() method
* and the **plugin.json** file.
*/
public function __construct($pluginName = false)
{
if (empty($pluginName)) {
$pluginName = explode('\\', get_class($this));
$pluginName = end($pluginName);
}
$this->pluginName = $pluginName;
$metadataLoader = new MetadataLoader($pluginName);
$this->pluginInformation = $metadataLoader->load();
if ($this->hasDefinedPluginInformationInPluginClass() && $metadataLoader->hasPluginJson()) {
throw new \Exception('Plugin ' . $pluginName . ' has defined the method getInformation() and as well as having a plugin.json file. Please delete the getInformation() method from the plugin class. Alternatively, you may delete the plugin directory from plugins/' . $pluginName);
}
$this->cache = new PersistentCache('Plugin' . $pluginName);
}