예제 #1
0
 /**
  * Uninstalls plugin
  *
  * @param string $pluginKey
  */
 public function uninstall($pluginKey)
 {
     if (empty($pluginKey)) {
         throw new LogicException("Empty plugin key provided for uninstall");
     }
     $pluginDto = $this->findPluginByKey(trim($pluginKey));
     if ($pluginDto === null) {
         throw new LogicException("Invalid plugin key - `{$pluginKey}` provided for uninstall!");
     }
     $plugin = new OW_Plugin($pluginDto);
     // trigger event
     OW::getEventManager()->trigger(new OW_Event(OW_EventManager::ON_BEFORE_PLUGIN_UNINSTALL, array("pluginKey" => $pluginDto->getKey())));
     $this->includeScript($plugin->getRootDir() . BOL_PluginService::SCRIPT_DEACTIVATE);
     $this->includeScript($plugin->getRootDir() . BOL_PluginService::SCRIPT_UNINSTALL);
     // delete plugin work dirs
     $dirsToRemove = array($plugin->getPluginFilesDir(), $plugin->getUserFilesDir(), $plugin->getPublicStaticDir());
     foreach ($dirsToRemove as $dir) {
         if (file_exists($dir)) {
             UTIL_File::removeDir($dir);
         }
     }
     // remove plugin configs
     OW::getConfig()->deletePluginConfigs($pluginDto->getKey());
     // delete language prefix
     $prefixId = BOL_LanguageService::getInstance()->findPrefixId($pluginDto->getKey());
     if (!empty($prefixId)) {
         BOL_LanguageService::getInstance()->deletePrefix($prefixId, true);
     }
     //delete authorization stuff
     BOL_AuthorizationService::getInstance()->deleteGroup($pluginDto->getKey());
     // drop plugin tables
     $tables = OW::getDbo()->queryForColumnList("SHOW TABLES LIKE '" . str_replace('_', '\\_', OW_DB_PREFIX) . $pluginDto->getKey() . "\\_%'");
     if (!empty($tables)) {
         $query = "DROP TABLE ";
         foreach ($tables as $table) {
             $query .= "`" . $table . "`,";
         }
         $query = substr($query, 0, -1);
         OW::getDbo()->query($query);
     }
     //remove entry in DB
     $this->deletePluginById($pluginDto->getId());
     $this->updatePluginListCache();
     // trigger event
     OW::getEventManager()->trigger(new OW_Event(OW_EventManager::ON_AFTER_PLUGIN_UNINSTALL, array("pluginKey" => $pluginDto->getKey())));
 }