Piwik\Settings\Storage\Backend\PluginSettingsTable::removeAllSettingsForPlugin PHP Method

removeAllSettingsForPlugin() public static method

Unsets all settings for a plugin. The settings will be removed from the database. Used when a plugin is uninstalled.
public static removeAllSettingsForPlugin ( string $pluginName )
$pluginName string
    public static function removeAllSettingsForPlugin($pluginName)
    {
        $table = Common::prefixTable('plugin_setting');
        Db::get()->query(sprintf('DELETE FROM %s WHERE plugin_name = ?', $table), array($pluginName));
    }

Usage Example

Esempio n. 1
0
 /**
  * Uninstalls a Plugin (deletes plugin files from the disk)
  * Only deactivated plugins can be uninstalled
  *
  * @param $pluginName
  * @throws \Exception
  * @return bool
  */
 public function uninstallPlugin($pluginName)
 {
     if ($this->isPluginLoaded($pluginName)) {
         throw new \Exception("To uninstall the plugin {$pluginName}, first disable it in Piwik > Settings > Plugins");
     }
     $this->loadAllPluginsAndGetTheirInfo();
     SettingsStorage\Backend\PluginSettingsTable::removeAllSettingsForPlugin($pluginName);
     SettingsStorage\Backend\MeasurableSettingsTable::removeAllSettingsForPlugin($pluginName);
     $this->executePluginDeactivate($pluginName);
     $this->executePluginUninstall($pluginName);
     $this->removePluginFromPluginsInstalledConfig($pluginName);
     $this->unloadPluginFromMemory($pluginName);
     $this->removePluginFromConfig($pluginName);
     $this->removeInstalledVersionFromOptionTable($pluginName);
     $this->clearCache($pluginName);
     self::deletePluginFromFilesystem($pluginName);
     if ($this->isPluginInFilesystem($pluginName)) {
         return false;
     }
     /**
      * Event triggered after a plugin has been uninstalled.
      *
      * @param string $pluginName The plugin that has been uninstalled.
      */
     Piwik::postEvent('PluginManager.pluginUninstalled', array($pluginName));
     return true;
 }