N°9567 - WIP

code style
This commit is contained in:
odain
2026-05-06 17:05:56 +02:00
parent a289cd0b0e
commit 55698149d1
2 changed files with 45 additions and 12 deletions

View File

@@ -21,11 +21,12 @@
use Combodo\iTop\PhpParser\Evaluation\PhpExpressionEvaluator;
use Combodo\iTop\Setup\ModuleDiscovery\ModuleFileReader;
use Combodo\iTop\Setup\ModuleDiscovery\ModuleFileReaderException;
use Combodo\iTop\Test\UnitTest\Integration\ExtensionsMapTest;
/**
* Choice of the modules to be installed
*/
class WizStepModulesChoice extends WizardStep
class WizStepModulesChoice extends AbstractWizStepInstall
{
protected static string $SEP = '_';
protected bool $bUpgrade = false;
@@ -118,15 +119,44 @@ class WizStepModulesChoice extends WizardStep
return [$aExtensionsAdded, $aExtensionsRemoved, $aExtensionsNotUninstallable];
}
public function IsDataAuditEnabled(): bool
public static function GetSetupComponentsFromExtensions(Config $oConfig, array $aSelectedExtensions): array
{
$sPath = APPROOT.'env-production';
if (!is_dir($sPath)) {
SetupLog::Info("Reinstallation of an iTop from a backup (No env-production found). Setup data audit disabled");
$sSourceFile = APPROOT.'datamodels/2.x/installation.xml';
$oExtensionsMap = new iTopExtensionsMap();
$oExtensionsMap->LoadChoicesFromDatabase($oConfig);
$aOptions = $oExtensionsMap->GetAllExtensionsOptionInfo(false);
return false;
if (is_file($sSourceFile)) {
$aParams = new XMLParameters($sSourceFile);
$aSteps = $aParams->Get('steps', []);
// Display this step of the wizard only if there is something to display
if (count($aOptions) > 0) {
$aSteps[] = [
'title' => 'Extensions',
'description' => '<h2>Select additional extensions to install. You can launch the installation again to install new extensions or remove installed ones.</h2>',
'banner' => '/images/icons/icons8-puzzle.svg',
'options' => $aOptions,
];
}
} else {
//legacy package
$aSteps = [
[
'title' => 'Modules Selection',
'description' => '<h2>Select the modules to install. You can launch the installation again to install new modules, but you cannot remove already installed modules.</h2>',
'banner' => '/images/icons/icons8-apps-tab.svg',
'options' => $aOptions,
],
];
}
return true;
$aRes = [];
foreach ($aSteps as $aStep) {
}
return [];
}
public function UpdateWizardStateAndGetNextStep($bMoveForward = true): WizardState
@@ -861,11 +891,7 @@ EOF
return 'Non-uninstallable extension missing';
}
if ($this->GetStepInfo(1 + $this->GetStepIndex()) === null && $this->IsDataAuditEnabled()) {
return 'Check compatibility';
}
return 'Next';
return 'Check compatibility';
}
}

View File

@@ -1391,4 +1391,11 @@ HTML,
$this->assertEquals($sExpectedHTML, $oPage->sContent);
}
public function testGetSetupComponentsFromExtensions()
{
$aSelectedExtensions = ["itop-config-mgmt-core","itop-config-mgmt-datacenter","itop-config-mgmt-end-user","itop-config-mgmt-storage","itop-config-mgmt-virtualization","itop-container-mgmt","itop-service-mgmt-enterprise","itop-ticket-mgmt-simple-ticket","itop-ticket-mgmt-simple-ticket-enhanced-portal","itop-change-mgmt-simple","itop-kown-error-mgmt","itop-problem-mgmt","combodo-oauth2-client","combodo-mfa-extended","combodo-data-replication","combodo-api-playground","combodo-snapshot"];
$aExpected = json_decode('[{"_0":"_0","_1":"_1","_2":"_2","_3":"_3","_4":"_4","_4_0":"_4_0"},{"_0":"_0"},{"_0":"_0","_0_0":"_0_0"},{"_0":"_0"},{"_0":"_0","_1":"_1"},{"_0":"_0","_1":"_1","_3":"_3","_4":"_4","_5":"_5"}]', true);
$this->assertEquals($aExpected, \WizStepModulesChoice::GetSetupComponentsFromExtensions($aSelectedExtensions));
}
}