Skip to content

Commit

Permalink
adds update to rename plugin in exisiting config
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Feb 3, 2020
1 parent c7bcb81 commit f0fc299
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions core/Updates/4.0.0-b1.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace Piwik\Updates;

use Piwik\Cache;
use Piwik\Config;
use Piwik\Updater;
use Piwik\Updates as PiwikUpdates;
use Piwik\Updater\Migration\Factory as MigrationFactory;
Expand Down Expand Up @@ -45,5 +47,31 @@ public function getMigrations(Updater $updater)
public function doUpdate(Updater $updater)
{
$updater->executeMigrations(__FILE__, $this->getMigrations($updater));

$this->renameTrackerJsPluginInConfig();

Cache::flushAll();
}

protected function renameTrackerJsPluginInConfig()
{
$updater = new Updater();
$updater->markComponentSuccessfullyUninstalled('CustomPiwikJs');

$config = Config::getInstance();

foreach ($config->Plugins['Plugins'] as $index => $plugin) {
if ($plugin === 'CustomPiwikJs') {
$config->Plugins['Plugins'][$index] = 'CustomTrackerJs';
}
}

foreach ($config->PluginsInstalled['PluginsInstalled'] as $index => $plugin) {
if ($plugin === 'CustomPiwikJs') {
$config->PluginsInstalled['PluginsInstalled'][$index] = 'CustomTrackerJs';
}
}

$config->forceSave();
}
}

0 comments on commit f0fc299

Please sign in to comment.