diff --git a/core/metamodel.class.php b/core/metamodel.class.php index e8c09850c..8aa9131d4 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -40,18 +40,6 @@ require_once(APPROOT.'core/relationgraph.class.inc.php'); // const VERSION = '1.0.0'; // } -/** - * add some description here... - * - * @package iTopORM - */ -define('ENUM_CHILD_CLASSES_EXCLUDETOP', 1); -/** - * add some description here... - * - * @package iTopORM - */ -define('ENUM_CHILD_CLASSES_ALL', 2); /** * add some description here... * diff --git a/core/modelreflection.class.inc.php b/core/modelreflection.class.inc.php index 2b4592f52..cb7885d4b 100644 --- a/core/modelreflection.class.inc.php +++ b/core/modelreflection.class.inc.php @@ -23,7 +23,21 @@ * @copyright Copyright (C) 2013 Combodo SARL * @license http://opensource.org/licenses/AGPL-3.0 */ - + +/** + * Exclude the parent class from the list + * + * @package iTopORM + */ +define('ENUM_CHILD_CLASSES_EXCLUDETOP', 1); +/** + * Include the parent class in the list + * + * @package iTopORM +*/ +define('ENUM_CHILD_CLASSES_ALL', 2); + + abstract class ModelReflection { abstract public function GetClassIcon($sClass, $bImgTag = true); @@ -62,6 +76,9 @@ abstract class ModelReflection } abstract public function GetIconSelectionField($sCode, $sLabel = '', $defaultValue = ''); + + abstract public function GetRootClass($sClass); + abstract public function EnumChildClasses($sClass, $iOption = ENUM_CHILD_CLASSES_EXCLUDETOP); } abstract class QueryReflection @@ -234,6 +251,16 @@ class ModelReflectionRuntime extends ModelReflection { return new RunTimeIconSelectionField($sCode, $sLabel, $defaultValue); } + + public function GetRootClass($sClass) + { + return MetaModel::GetRootClass($sClass); + } + + public function EnumChildClasses($sClass, $iOption = ENUM_CHILD_CLASSES_EXCLUDETOP) + { + return MetaModel::EnumChildClasses($sClass, $iOption); + } } diff --git a/core/oql/oqlquery.class.inc.php b/core/oql/oqlquery.class.inc.php index e3a765311..07511f69a 100644 --- a/core/oql/oqlquery.class.inc.php +++ b/core/oql/oqlquery.class.inc.php @@ -580,13 +580,13 @@ class OqlUnionQuery extends OqlQuery if ($iQuery == 0) { // Establish the reference - $sRootClass = MetaModel::GetRootClass($aData['class']); + $sRootClass = $oModelReflection->GetRootClass($aData['class']); } else { - if (MetaModel::GetRootClass($aData['class']) != $sRootClass) + if ($oModelReflection->GetRootClass($aData['class']) != $sRootClass) { - $aSubclasses = MetaModel::EnumChildClasses($sRootClass, ENUM_CHILD_CLASSES_ALL); + $aSubclasses = $oModelReflection->EnumChildClasses($sRootClass, ENUM_CHILD_CLASSES_ALL); throw new OqlNormalizeException('Incompatible classes: could not find a common ancestor', $sSourceQuery, $aData['class_name'], $aSubclasses); } }