Uninstall.php
50 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Matomo - free/libre analytics platform |
| 5 | * |
| 6 | * @link https://matomo.org |
| 7 | * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 8 | */ |
| 9 | namespace Piwik\Updater\Migration\Plugin; |
| 10 | |
| 11 | use Piwik\Config; |
| 12 | use Piwik\Plugin; |
| 13 | use Piwik\Updater\Migration; |
| 14 | /** |
| 15 | * Uninstalls the given plugin during the update |
| 16 | */ |
| 17 | class Uninstall extends Migration |
| 18 | { |
| 19 | /** |
| 20 | * @var string |
| 21 | */ |
| 22 | private $pluginName; |
| 23 | /** |
| 24 | * @var Plugin\Manager |
| 25 | */ |
| 26 | private $pluginManager; |
| 27 | public function __construct(Plugin\Manager $pluginManager, $pluginName) |
| 28 | { |
| 29 | $this->pluginManager = $pluginManager; |
| 30 | $this->pluginName = $pluginName; |
| 31 | } |
| 32 | public function __toString() |
| 33 | { |
| 34 | $domain = Config::getLocalConfigPath() == Config::getDefaultLocalConfigPath() ? '' : Config::getHostname(); |
| 35 | $domainArg = !empty($domain) ? "--matomo-domain=\"{$domain}\" " : ''; |
| 36 | return sprintf('./console %splugin:uninstall "%s"', $domainArg, $this->pluginName); |
| 37 | } |
| 38 | public function shouldIgnoreError($exception) |
| 39 | { |
| 40 | return \true; |
| 41 | } |
| 42 | public function exec() |
| 43 | { |
| 44 | $this->pluginManager->uninstallPlugin($this->pluginName); |
| 45 | // uninstallPlugin() loads all plugins in the filesystem, which we don't want for the rest of the updates |
| 46 | $this->pluginManager->unloadPlugins(); |
| 47 | $this->pluginManager->loadActivatedPlugins(); |
| 48 | } |
| 49 | } |
| 50 |