/** * Compute the "RelatedObjects" (reverse or "up" direction) for the set * for the specified relation * * @param string $sRelCode The code of the relation to use for the computation * @param int $iMaxDepth Maximum recursion depth * @param boolean $bEnableReduncancy Whether or not to take into account the redundancy * * @return RelationGraph The graph of all the related objects */ public function GetRelatedObjectsUp($sRelCode, $iMaxDepth = 99, $bEnableRedundancy = true) { $oGraph = new RelationGraph(); $this->Rewind(); while ($oObj = $this->Fetch()) { $oGraph->AddSinkObject($oObj); } $oGraph->ComputeRelatedObjectsUp($sRelCode, $iMaxDepth, $bEnableRedundancy); return $oGraph; }
/** * Compute the "RelatedObjects" in the reverse way * * @param string $sRelCode The code of the relation to use for the computation * @param array $asourceObjects The objects to start with * @param int $iMaxDepth * @param boolean $bEnableReduncancy * * @return RelationGraph The graph of all the related objects */ public static function GetRelatedObjectsUp($sRelCode, $aSourceObjects, $iMaxDepth = 99, $bEnableRedundancy = true, $aContexts = array()) { $oGraph = new RelationGraph(); foreach ($aSourceObjects as $oObject) { $oGraph->AddSinkObject($oObject); } foreach ($aContexts as $key => $sOQL) { $oGraph->AddContextQuery($key, $sOQL); } $oGraph->ComputeRelatedObjectsUp($sRelCode, $iMaxDepth, $bEnableRedundancy); return $oGraph; }