mirror of
https://github.com/Combodo/iTop.git
synced 2026-07-06 23:06:38 +02:00
* N°9454 - Make MTT compatible with the dry run * N°9454 - Make MTT compatible with the dry run * N°9454 - Cleaning up configuration handling * N°9454 - Cleanup code * N°9454 - Remove writable directories * Update setup/wizardsteps/WizStepLandingBeforeAudit.php Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * Update setup/runtimeenv.class.inc.php Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * N°9454 - Secure target environment wizard step done form submission --------- Co-authored-by: Eric Espie <eric.espie@combodo.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
74 lines
1.9 KiB
PHP
74 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Combodo\iTop\Setup\FeatureRemoval;
|
|
|
|
use iTopExtensionsMap;
|
|
use RunTimeEnvironment;
|
|
use SetupUtils;
|
|
|
|
class DryRemovalRuntimeEnvironment extends RunTimeEnvironment
|
|
{
|
|
protected array $aExtensionsToRemoveByCode;
|
|
|
|
/**
|
|
* Toolset for building a run-time environment
|
|
*
|
|
* @param string $sSourceEnv: environment from which setup is inspired to simulate extension removal and usee CompileFrom...
|
|
*/
|
|
public function __construct($sSourceEnv = ITOP_DEFAULT_ENV, array $aExtensionCodesToRemove = [])
|
|
{
|
|
parent::__construct($sSourceEnv, false);
|
|
$this->aExtensionsToRemoveByCode = $aExtensionCodesToRemove;
|
|
$this->Prepare($sSourceEnv, $this->sBuildEnv);
|
|
}
|
|
|
|
/**
|
|
* @param string $sSourceEnv
|
|
* @param string $sBuildEnv
|
|
* @return void
|
|
* @throws \MissingDependencyException
|
|
*/
|
|
private function Prepare(string $sSourceEnv, string $sBuildEnv)
|
|
{
|
|
$this->Cleanup();
|
|
SetupUtils::copydir(APPROOT."/data/$sSourceEnv-modules", APPROOT."/data/$sBuildEnv-modules");
|
|
SetupUtils::copydir(APPROOT."/conf/$sSourceEnv", APPROOT."/conf/$sBuildEnv");
|
|
|
|
$this->DeclareExtensionAsRemoved($this->aExtensionsToRemoveByCode);
|
|
}
|
|
|
|
private function DeclareExtensionAsRemoved(array $aExtensionCodes): void
|
|
{
|
|
$oExtensionsMap = new iTopExtensionsMap($this->sBuildEnv);
|
|
$oExtensionsMap->DeclareExtensionAsRemoved($aExtensionCodes);
|
|
}
|
|
|
|
public function Cleanup(): void
|
|
{
|
|
$sEnv = $this->sBuildEnv;
|
|
|
|
//keep this folder empty
|
|
SetupUtils::tidydir(APPROOT."/env-$sEnv");
|
|
|
|
$aFolders = [
|
|
APPROOT."/data/$sEnv-modules",
|
|
APPROOT."/data/cache-$sEnv",
|
|
APPROOT."/conf/$sEnv",
|
|
];
|
|
foreach ($aFolders as $sFolder) {
|
|
SetupUtils::tidydir($sFolder);
|
|
SetupUtils::rmdir_safe($sFolder);
|
|
}
|
|
|
|
$sFiles = [
|
|
APPROOT."/data/datamodel-$sEnv.xml",
|
|
APPROOT."/data/$sEnv.delta.prev.xml",
|
|
];
|
|
foreach ($sFiles as $sFile) {
|
|
if (is_file($sFile)) {
|
|
@unlink($sFile);
|
|
}
|
|
}
|
|
}
|
|
}
|