mirror of
https://github.com/Combodo/iTop.git
synced 2026-09-29 21:09:10 +02:00
Possibility to introduce a delta (not in a module) at compile time
SVN:trunk[2817]
This commit is contained in:
@@ -214,7 +214,7 @@ class ApplicationInstaller
|
||||
}
|
||||
}
|
||||
|
||||
self::DoCompile($aSelectedModules, $sSourceDir, $sExtensionDir, $sTargetDir, $sWorkspaceDir, $bUseSymbolicLinks);
|
||||
self::DoCompile($aSelectedModules, $sSourceDir, $sExtensionDir, $sTargetDir, $sTargetEnvironment, $bUseSymbolicLinks);
|
||||
|
||||
$aResult = array(
|
||||
'status' => self::OK,
|
||||
@@ -424,7 +424,7 @@ class ApplicationInstaller
|
||||
}
|
||||
|
||||
|
||||
protected static function DoCompile($aSelectedModules, $sSourceDir, $sExtensionDir, $sTargetDir, $sWorkspaceDir = '', $bUseSymbolicLinks = false)
|
||||
protected static function DoCompile($aSelectedModules, $sSourceDir, $sExtensionDir, $sTargetDir, $sEnvironment, $bUseSymbolicLinks = false)
|
||||
{
|
||||
SetupPage::log_info("Compiling data model.");
|
||||
|
||||
@@ -480,13 +480,11 @@ class ApplicationInstaller
|
||||
$oFactory->LoadModule($oModule);
|
||||
}
|
||||
}
|
||||
if (strlen($sWorkspaceDir) > 0)
|
||||
$sDeltaFile = APPROOT.'data/'.$sEnvironment.'.delta.xml';
|
||||
if (file_exists($sDeltaFile))
|
||||
{
|
||||
$oWorkspace = new MFWorkspace(APPROOT.$sWorkspaceDir);
|
||||
if (file_exists($oWorkspace->GetWorkspacePath()))
|
||||
{
|
||||
$oFactory->LoadModule($oWorkspace);
|
||||
}
|
||||
$oDelta = new MFDeltaModule($sDeltaFile);
|
||||
$oFactory->LoadModule($oDelta);
|
||||
}
|
||||
//$oFactory->Dump();
|
||||
if ($oFactory->HasLoadErrors())
|
||||
|
||||
@@ -102,11 +102,14 @@ class MFCompiler
|
||||
$sModuleName = $oModule->GetName();
|
||||
$sModuleVersion = $oModule->GetVersion();
|
||||
|
||||
$sModuleRootDir = realpath($oModule->GetRootDir());
|
||||
$sRelativeDir = basename($sModuleRootDir);
|
||||
|
||||
// Push the other module files
|
||||
SetupUtils::copydir($sModuleRootDir, $sTargetDir.'/'.$sRelativeDir, $bUseSymbolicLinks);
|
||||
$sModuleRootDir = $oModule->GetRootDir();
|
||||
if ($sModuleRootDir != '')
|
||||
{
|
||||
$sModuleRootDir = realpath($sModuleRootDir);
|
||||
$sRelativeDir = basename($sModuleRootDir);
|
||||
// Push the other module files
|
||||
SetupUtils::copydir($sModuleRootDir, $sTargetDir.'/'.$sRelativeDir, $bUseSymbolicLinks);
|
||||
}
|
||||
|
||||
$sCompiledCode = '';
|
||||
|
||||
|
||||
@@ -131,6 +131,45 @@ class MFModule
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* MFDeltaModule: an optional module, made of a single file
|
||||
* @package ModelFactory
|
||||
*/
|
||||
class MFDeltaModule extends MFModule
|
||||
{
|
||||
public function __construct($sDeltaFile)
|
||||
{
|
||||
$this->sId = 'datamodel-delta';
|
||||
|
||||
$this->sName = 'delta';
|
||||
$this->sVersion = '1.0';
|
||||
|
||||
$this->sRootDir = '';
|
||||
$this->sLabel = 'Additional Delta';
|
||||
$this->aDataModels = array($sDeltaFile);
|
||||
}
|
||||
|
||||
public function GetName()
|
||||
{
|
||||
return ''; // Objects created inside this pseudo module retain their original module's name
|
||||
}
|
||||
|
||||
public function GetRootDir()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function GetModuleDir()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function GetDictionaryFiles()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ModelFactory: the class that manages the in-memory representation of the XML MetaModel
|
||||
* @package ModelFactory
|
||||
|
||||
@@ -35,6 +35,8 @@ define ('MODULE_ACTION_IMPOSSIBLE', 3);
|
||||
define ('ROOT_MODULE', '_Root_'); // Convention to store IN MEMORY the name/version of the root module i.e. application
|
||||
define ('DATAMODEL_MODULE', 'datamodel'); // Convention to store the version of the datamodel
|
||||
|
||||
|
||||
|
||||
class RunTimeEnvironment
|
||||
{
|
||||
protected $sTargetEnv;
|
||||
@@ -313,6 +315,14 @@ class RunTimeEnvironment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sDeltaFile = APPROOT.'data/'.$sSourceEnv.'.delta.xml';
|
||||
if (file_exists($sDeltaFile))
|
||||
{
|
||||
$oDelta = new MFDeltaModule($sDeltaFile);
|
||||
$aRet[] = $oDelta;
|
||||
}
|
||||
|
||||
return $aRet;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user