mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-06 01:28:41 +02:00
* N°8761 - Assist in cleaning up data prior to uninstalling extensions - handle transaction ID + add deletion plan screen * N°8761 - poc of deletion plan screen * code style * N°8761 - WIP deletion plan execution * Delete all parent classes objects + cleanup * 🌐 translation (EN only) * remove history * In case of no leaf class to remove, delete also the child classes * 🎨 refactor & fix typo * Analysis not stored anymore in DB * Analysis for removed modules * 🌐 dico * Add spinner to setup button "Go to backoffice" * Fix count after PR review * Fix after PR review * Fix Number of elements to remove * Fix arrays --------- Co-authored-by: odain <olivier.dain@combodo.com>
81 lines
2.2 KiB
PHP
81 lines
2.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
* @copyright Copyright (C) 2010-2026 Combodo SAS
|
|
* @license http://opensource.org/licenses/AGPL-3.0
|
|
*/
|
|
|
|
namespace Combodo\iTop\DataFeatureRemoval\Service;
|
|
|
|
use iTopExtension;
|
|
use iTopExtensionsMap;
|
|
use MetaModel;
|
|
|
|
class DataFeatureRemoverExtensionService
|
|
{
|
|
private static DataFeatureRemoverExtensionService $oInstance;
|
|
|
|
private array $aItopExtensions = [];
|
|
private array $aIncludingExtensionsByModuleName = [];
|
|
|
|
protected function __construct()
|
|
{
|
|
}
|
|
|
|
final public static function GetInstance(): DataFeatureRemoverExtensionService
|
|
{
|
|
if (!isset(self::$oInstance)) {
|
|
self::$oInstance = new DataFeatureRemoverExtensionService();
|
|
}
|
|
|
|
return self::$oInstance;
|
|
}
|
|
|
|
final public static function SetInstance(?DataFeatureRemoverExtensionService $oInstance): void
|
|
{
|
|
self::$oInstance = $oInstance;
|
|
}
|
|
|
|
/**
|
|
* @param string $sModuleName
|
|
*
|
|
* @return array
|
|
* @throws \Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalException
|
|
*/
|
|
public function GetIncludingExtensions(string $sModuleName): array
|
|
{
|
|
if (count($this->aIncludingExtensionsByModuleName) === 0) {
|
|
foreach ($this->ReadItopExtensions() as $oExtension) {
|
|
$aModuleNames = $oExtension->aModules;
|
|
if (is_array($aModuleNames) && count($aModuleNames) > 0) {
|
|
foreach ($aModuleNames as $sModule) {
|
|
$aExtensions = $this->aIncludingExtensionsByModuleName[$sModule] ?? [];
|
|
$aExtensions[] = $oExtension->sLabel.'/'.$oExtension->sVersion;
|
|
$this->aIncludingExtensionsByModuleName[$sModule] = $aExtensions;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return $this->aIncludingExtensionsByModuleName[$sModuleName] ?? [];
|
|
}
|
|
|
|
/**
|
|
* @return iTopExtension[]
|
|
*/
|
|
public function ReadItopExtensions(): array
|
|
{
|
|
if (count($this->aItopExtensions) === 0) {
|
|
$oExtensionsMap = new iTopExtensionsMap();
|
|
$oExtensionsMap->LoadInstalledExtensionsFromDatabase(MetaModel::GetConfig());
|
|
$this->aItopExtensions = $oExtensionsMap->GetAllExtensionsToDisplayInSetup(true);
|
|
|
|
uasort($this->aItopExtensions, function (iTopExtension $oiTopExtension1, iTopExtension $oiTopExtension2) {
|
|
return strcmp($oiTopExtension1->sLabel, $oiTopExtension2->sLabel);
|
|
});
|
|
}
|
|
|
|
return $this->aItopExtensions;
|
|
}
|
|
}
|