diff --git a/core/dbobjectset.class.php b/core/dbobjectset.class.php index 903663afd..b87e04b16 100644 --- a/core/dbobjectset.class.php +++ b/core/dbobjectset.class.php @@ -72,6 +72,8 @@ class DBObjectSet return $oRetSet; } + // create an object set ex nihilo + // input = array of objects static public function FromArray($sClass, $aObjects) { $oFilter = new CMDBSearchFilter($sClass); @@ -81,6 +83,28 @@ class DBObjectSet return $oRetSet; } + // create an object set ex nihilo + // aClasses = array of (alias => class) + // input = array of (array of (classalias => object)) + static public function FromArrayAssoc($aClasses, $aObjects) + { + // In a perfect world, we should create a complete tree of DBObjectSearch, + // but as we lack most of the information related to the objects, + // let's create one search definition + $sClass = reset($this->m_aClasses); + $sAlias = key($this->m_aClasses); + $oFilter = new CMDBSearchFilter($sClass, $sAlias); + + $oRetSet = new self($oFilter); + $oRetSet->m_bLoaded = true; // no DB load + + foreach($aObjects as $rowIndex => $aObjectsByClassAlias) + { + $oRetSet->AddObjectExtended($aObjectsByClassAlias); + } + return $oRetSet; + } + static public function FromLinkSet($oObject, $sLinkSetAttCode, $sExtKeyToRemote) { $oLinkAttCode = MetaModel::GetAttributeDef(get_class($oObject), $sLinkSetAttCode);