private function installPluginIfNecessary(Plugin $plugin)
{
$pluginName = $plugin->getPluginName();
$saveConfig = false;
// is the plugin already installed or is it the first time we activate it?
$pluginsInstalled = $this->getInstalledPluginsName();
if (!$this->isPluginInstalled($pluginName)) {
$this->executePluginInstall($plugin);
$pluginsInstalled[] = $pluginName;
$this->updatePluginsInstalledConfig($pluginsInstalled);
$updater = new Updater();
$updater->markComponentSuccessfullyUpdated($plugin->getPluginName(), $plugin->getVersion(), $isNew = true);
$saveConfig = true;
/**
* Event triggered after a new plugin has been installed.
*
* Note: Might be triggered more than once if the config file is not writable
*
* @param string $pluginName The plugin that has been installed.
*/
Piwik::postEvent('PluginManager.pluginInstalled', array($pluginName));
}
if ($saveConfig) {
PiwikConfig::getInstance()->forceSave();
$this->clearCache($pluginName);
}
}