mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-20 00:58:48 +02:00
XML Modelization of the relations: declare the relations based on the XML (implicit declaration in XML, explicit in PHP -thus retrocompatible)
SVN:trunk[3522]
This commit is contained in:
@@ -34,6 +34,7 @@ class MFCompiler
|
||||
protected $aLog;
|
||||
protected $sMainPHPCode; // Code that goes into core/main.php
|
||||
protected $aSnippets;
|
||||
protected $aRelations;
|
||||
|
||||
public function __construct($oModelFactory)
|
||||
{
|
||||
@@ -45,6 +46,7 @@ class MFCompiler
|
||||
$this->sMainPHPCode .= " * This file was automatically generated by the compiler on ".date('Y-m-d H:i:s')." -- DO NOT EDIT\n";
|
||||
$this->sMainPHPCode .= " */\n";
|
||||
$this->aSnippets = array();
|
||||
$this->aRelations = array();
|
||||
}
|
||||
|
||||
protected function Log($sText)
|
||||
@@ -443,7 +445,20 @@ EOF;
|
||||
$this->sMainPHPCode .= $aSnippet['content']."\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (count($this->aRelations) > 0)
|
||||
{
|
||||
$this->sMainPHPCode .= "\n";
|
||||
$this->sMainPHPCode .= "/**\n";
|
||||
$this->sMainPHPCode .= " * Relations\n";
|
||||
$this->sMainPHPCode .= " */\n";
|
||||
foreach($this->aRelations as $sRelationCode => $aData)
|
||||
{
|
||||
$sRelCodeSafe = addslashes($sRelationCode);
|
||||
$this->sMainPHPCode .= "MetaModel::RegisterRelation('$sRelCodeSafe');\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Write core/main.php
|
||||
SetupUtils::builddir($sTempTargetDir.'/core');
|
||||
$sPHPFile = $sTempTargetDir.'/core/main.php';
|
||||
@@ -1397,6 +1412,7 @@ EOF;
|
||||
if ($oRelation->tagName != 'relation') continue;
|
||||
|
||||
$sRelationId = $oRelation->getAttribute('id');
|
||||
$this->aRelations[$sRelationId] = array('id' => $sRelationId);
|
||||
|
||||
$oNeighbours = $oRelation->GetUniqueElement('neighbours');
|
||||
foreach($oNeighbours->childNodes as $oNeighbour)
|
||||
|
||||
Reference in New Issue
Block a user