public function activatePlugin($pluginName)
{
$plugins = $this->pluginList->getActivatedPlugins();
if (in_array($pluginName, $plugins)) {
// plugin is already activated
return;
}
if (!$this->isPluginInFilesystem($pluginName)) {
throw new \Exception("Plugin '{$pluginName}' cannot be found in the filesystem in plugins/ directory.");
}
$this->deactivateThemeIfTheme($pluginName);
// Load plugin
$plugin = $this->loadPlugin($pluginName);
if ($plugin === null) {
throw new \Exception("The plugin '{$pluginName}' was found in the filesystem, but could not be loaded.'");
}
$this->installPluginIfNecessary($plugin);
$plugin->activate();
EventDispatcher::getInstance()->postPendingEventsTo($plugin);
$this->pluginsToLoad[] = $pluginName;
$this->updatePluginsConfig($this->pluginsToLoad);
PiwikConfig::getInstance()->forceSave();
$this->clearCache($pluginName);
/**
* Event triggered after a plugin has been activated.
*
* @param string $pluginName The plugin that has been activated.
*/
Piwik::postEvent('PluginManager.pluginActivated', array($pluginName));
}