/** * Perform uninstall operation for module * * @throws NotInstalledException * @throws CoreModuleRemovalConstraintException */ public function uninstall() { if (!Informations::isModuleInstalled($this->moduleSlug)) { $exceptionMessage = _("The given module is not installed"); throw new NotInstalledException($this->colorizeMessage($exceptionMessage, 'danger'), 1109); } $coreModule = Informations::getCoreModuleList(); if (in_array($this->moduleSlug, $coreModule)) { $exceptionMessage = _("This module is a core module and therefore can't be uninstalled"); throw new CoreModuleRemovalConstraintException($this->colorizeMessage($exceptionMessage, 'danger'), 1103); } // Starting Message $message = _("Starting removal of %s module"); $this->displayOperationMessage($this->colorizeMessage(sprintf($message, $this->moduleFullName), 'info')); // Performing pre operation check $this->checkOperationValidity('uninstall'); // Set TemporaryVersion $this->versionManager->setTemporaryVersion('uninstall', true); $this->moduleId = Informations::getModuleIdByName($this->moduleSlug); // $this->preRemove(); $this->removeHook(); // Remove old static files $this->removeStaticFiles(); //Remove validators $this->removeValidators(); // Custom removal of the module $this->customRemove(); $this->postRemove(); // Ending Message $message = _("Removal of %s module complete"); $this->displayOperationMessage($this->colorizeMessage(sprintf($message, $this->moduleFullName), 'success')); }
/** * * @param string $operationType * @param string $targetDbName * @return array */ private static function getAllXmlFiles($operationType = 'update', $targetDbName = 'centreon') { // Initialize configuration $di = Di::getDefault(); $config = $di->get('config'); $centreonPath = $config->get('global', 'centreon_path'); $xmlDbFiles = glob(realpath(rtrim($centreonPath, '/') . '/install/db/' . $targetDbName) . '/*.xml'); // Module if ($operationType == 'update') { $registeredModules = Module::getList('name'); $registeredModules(array_merge($registeredModules, Informations::getCoreModuleList())); foreach ($registeredModules as $module) { $module['name'] = str_replace(' ', '', ucwords(str_replace('-', ' ', $module['name']))) . 'Module'; $xmlDbFiles = array_merge($xmlDbFiles, glob(realpath(rtrim($centreonPath, '/') . '/modules') . '/' . $module['name'] . '/install/db/' . $targetDbName . '/*.xml')); } } else { $xmlDbFiles = array_merge($xmlDbFiles, glob(realpath(rtrim($centreonPath, '/') . '/modules') . '/*Module/install/db/' . $targetDbName . '/*.xml')); } return $xmlDbFiles; }