Skip to content

Commit 435cb3d

Browse files
committed
N°9010 Refactor ComputeChoiceFlags
1 parent e6ecfe6 commit 435cb3d

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

setup/wizardsteps/WizStepModulesChoice.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,14 +666,26 @@ protected function GetStepInfo($idx = null)
666666
public function ComputeChoiceFlags(array $aChoice, string $sChoiceId, array $aSelectedComponents, bool $bAllDisabled, bool $bDisableUninstallCheck, bool $bUpgradeMode)
667667
{
668668
$oITopExtension = $this->oExtensionsMap->GetFromExtensionCode($aChoice['extension_code']);
669+
//If the extension is missing from disk, it won't exist in the ExtensionsMap, thus returning null
669670
$bCanBeUninstalled = isset($aChoice['uninstallable']) ? $aChoice['uninstallable'] === true || $aChoice['uninstallable'] === 'yes' : $oITopExtension->CanBeUninstalled();
670671
$bSelected = isset($aSelectedComponents[$sChoiceId]) && ($aSelectedComponents[$sChoiceId] == $sChoiceId);
671-
$bMandatory = (isset($aChoice['mandatory']) && $aChoice['mandatory']) || $bUpgradeMode && $oITopExtension->bInstalled && !$bCanBeUninstalled && !$bDisableUninstallCheck;
672-
673672
$bMissingFromDisk = isset($aChoice['missing']) && $aChoice['missing'] === true;
673+
$bMandatory = (isset($aChoice['mandatory']) && $aChoice['mandatory']);
674674
$bInstalled = $bMissingFromDisk || $oITopExtension->bInstalled;
675-
$bDisabled = $bMandatory || $bAllDisabled || $bMissingFromDisk;
676-
$bChecked = $bMandatory || $bSelected;
675+
676+
$bChecked = $bSelected;
677+
$bDisabled = false;
678+
if ($bMissingFromDisk) {
679+
$bDisabled = true;
680+
$bChecked = false;
681+
}
682+
elseif($bMandatory || $bInstalled && !$bCanBeUninstalled){
683+
$bDisabled = true;
684+
$bChecked = true;
685+
}
686+
if($bAllDisabled){
687+
$bDisabled = true;
688+
}
677689

678690
if (isset($aChoice['sub_options'])) {
679691
$aOptions = $aChoice['sub_options']['options'] ?? [];

0 commit comments

Comments
 (0)