From 183c3c1baf19eee58b2872fe287415c3dfd02bea Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Thu, 19 May 2022 16:30:06 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B04666=20-=20Core=20Update=20:=20handle=20?= =?UTF-8?q?modules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/RunTimeEnvironmentCoreUpdater.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/datamodels/2.x/itop-core-update/src/Service/RunTimeEnvironmentCoreUpdater.php b/datamodels/2.x/itop-core-update/src/Service/RunTimeEnvironmentCoreUpdater.php index fea0abaef..6715878e0 100644 --- a/datamodels/2.x/itop-core-update/src/Service/RunTimeEnvironmentCoreUpdater.php +++ b/datamodels/2.x/itop-core-update/src/Service/RunTimeEnvironmentCoreUpdater.php @@ -11,6 +11,7 @@ require_once(APPROOT."setup/runtimeenv.class.inc.php"); use Config; use Exception; +use ModelFactory; use RunTimeEnvironment; use SetupUtils; @@ -126,4 +127,49 @@ class RunTimeEnvironmentCoreUpdater extends RunTimeEnvironment } throw new Exception('No configuration file available'); } + + protected function GetMFModulesToCompile($sSourceEnv, $sSourceDir) + { + $aRet = parent::GetMFModulesToCompile($sSourceEnv, $sSourceDir); + + // Add new mandatory modules + $sSourceDirFull = APPROOT.$sSourceDir; + if (!is_dir($sSourceDirFull)) + { + throw new Exception("The source directory '$sSourceDirFull' does not exist (or could not be read)"); + } + $aDirsToCompile = array($sSourceDirFull); + if (is_dir(APPROOT.'extensions')) + { + $aDirsToCompile[] = APPROOT.'extensions'; + } + $sExtraDir = APPROOT.'data/'.$this->sTargetEnv.'-modules/'; + if (is_dir($sExtraDir)) + { + $aDirsToCompile[] = $sExtraDir; + } + + $aExtraDirs = $this->GetExtraDirsToScan($aDirsToCompile); + $aDirsToCompile = array_merge($aDirsToCompile, $aExtraDirs); + + $oFactory = new ModelFactory($aDirsToCompile); + $aModules = $oFactory->FindModules(); + $aAvailableModules = []; + /** @var \MFModule $oModule */ + foreach ($aModules as $oModule) { + $aAvailableModules[$oModule->GetName()] = $oModule; + } + foreach($this->oExtensionsMap->GetAllExtensions() as $oExtension) { + if ($oExtension->bMarkedAsChosen) { + foreach ($oExtension->aModules as $sModuleName) { + if (!isset($aRet[$sModuleName])) { + $aRet[$sModuleName] = $aAvailableModules[$sModuleName]; + } + } + } + } + + return $aRet; + } + }