mirror of
https://github.com/Combodo/iTop.git
synced 2026-06-04 07:02:15 +02:00
Compare commits
3 Commits
feature/95
...
issue/9179
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5f4595980 | ||
|
|
b96882721e | ||
|
|
56b5c374ae |
@@ -81,13 +81,13 @@ class ApplicationInstallSequencer extends StepSequencer
|
||||
return $this->ComputeNextStep($sStep);
|
||||
|
||||
case 'log-parameters':
|
||||
if (array_key_exists($sStep, $this->oParams->Get('optional_steps', []))) {
|
||||
if ($this->HasOptionalStep($sStep)) {
|
||||
$this->DoLogParameters();
|
||||
}
|
||||
return $this->ComputeNextStep($sStep);
|
||||
|
||||
case 'backup':
|
||||
if (array_key_exists($sStep, $this->oParams->Get('optional_steps', []))) {
|
||||
if ($this->HasOptionalStep($sStep, false)) {
|
||||
$aBackupOptions = $this->oParams->Get('optional_steps')['backup'];
|
||||
// __DB__-%Y-%m-%d
|
||||
$sDestination = $aBackupOptions['destination'];
|
||||
@@ -100,7 +100,7 @@ class ApplicationInstallSequencer extends StepSequencer
|
||||
|
||||
case 'migrate-before':
|
||||
$this->oRunTimeEnvironment->EnterMaintenanceMode($this->GetConfig());
|
||||
if (array_key_exists($sStep, $this->oParams->Get('optional_steps', []))) {
|
||||
if ($this->HasOptionalStep($sStep)) {
|
||||
$this->oRunTimeEnvironment->MigrateDataBeforeUpdateStructure($this->oParams->Get('mode'), $this->GetConfig());
|
||||
}
|
||||
return $this->ComputeNextStep($sStep);
|
||||
@@ -111,7 +111,7 @@ class ApplicationInstallSequencer extends StepSequencer
|
||||
return $this->ComputeNextStep($sStep);
|
||||
|
||||
case 'migrate-after':
|
||||
if (array_key_exists($sStep, $this->oParams->Get('optional_steps', []))) {
|
||||
if ($this->HasOptionalStep($sStep)) {
|
||||
$this->oRunTimeEnvironment->MigrateDataAfterUpdateStructure($this->oParams->Get('mode'), $this->GetConfig());
|
||||
}
|
||||
return $this->ComputeNextStep($sStep);
|
||||
@@ -191,13 +191,17 @@ class ApplicationInstallSequencer extends StepSequencer
|
||||
public function GetStepNames(): array
|
||||
{
|
||||
$aStepNames = [ ''];
|
||||
foreach (['log-parameters', 'backup', 'migrate-before'] as $sStepName) {
|
||||
if (array_key_exists($sStepName, $this->oParams->Get('optional_steps', []))) {
|
||||
$aStepNames [] = $sStepName;
|
||||
}
|
||||
if ($this->HasOptionalStep('log-parameters')) {
|
||||
$aStepNames [] = 'log-parameters';
|
||||
}
|
||||
if ($this->HasOptionalStep('backup', false)) {
|
||||
$aStepNames [] = 'backup';
|
||||
}
|
||||
if ($this->HasOptionalStep('migrate-before')) {
|
||||
$aStepNames [] = 'migrate-before';
|
||||
}
|
||||
$aStepNames [] = 'db-schema';
|
||||
if (array_key_exists('migrate-after', $this->oParams->Get('optional_steps', []))) {
|
||||
if ($this->HasOptionalStep('migrate-after')) {
|
||||
$aStepNames [] = 'migrate-after';
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ class DataAuditSequencer extends StepSequencer
|
||||
|
||||
protected function IsDataAuditRequired(): bool
|
||||
{
|
||||
if (! array_key_exists('setup-audit', $this->oParams->Get('optional_steps', []))) {
|
||||
if (!$this->HasOptionalStep('setup-audit', false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class DataAuditSequencer extends StepSequencer
|
||||
public function GetStepNames(): array
|
||||
{
|
||||
$aStepNames = [''];
|
||||
if (array_key_exists('copy', $this->oParams->Get('optional_steps', []))) {
|
||||
if ($this->HasOptionalStep('copy')) {
|
||||
$aStepNames[] = 'copy';
|
||||
}
|
||||
$aStepNames[] = 'compile';
|
||||
|
||||
@@ -233,4 +233,26 @@ abstract class StepSequencer
|
||||
* @return array (status => , message => , percentage-completed => , next-step => , next-step-label => )
|
||||
*/
|
||||
abstract public function ExecuteStep($sStep = '', $sInstallComment = null): array;
|
||||
|
||||
/**
|
||||
* Check whether an optional step is enabled in the "optional_steps" parameters. If optional_steps is not set, use $bDefaultValue as its default value
|
||||
*
|
||||
* @param $sStep
|
||||
* @param bool $bDefaultValue
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function HasOptionalStep($sStep, bool $bDefaultValue = true)
|
||||
{
|
||||
$aOptionalSteps = $this->oParams->Get('optional_steps', null);
|
||||
if (is_null($aOptionalSteps)) {
|
||||
return $bDefaultValue;
|
||||
}
|
||||
if (is_array($aOptionalSteps)) {
|
||||
return array_key_exists($sStep, $aOptionalSteps);
|
||||
}
|
||||
throw new Exception('Incorrect value for parameter optional_steps');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user