src/ORM/DataObject.php
public function relObject($fieldPath)
    {
        $object = null;
        $component = $this;

        // Parse all relations
        foreach (explode('.', $fieldPath) as $relation) {
            if (!$component) {
                return null;
            }

            // Inspect relation type
            if (ClassInfo::hasMethod($component, $relation)) {
                $component = $component->$relation();
            } elseif ($component instanceof Relation || $component instanceof DataList) {
                // $relation could either be a field (aggregate), or another relation
                $singleton = DataObject::singleton($component->dataClass());
                $component = $singleton->dbObject($relation) ?: $component->relation($relation);
            } elseif ($component instanceof DataObject && ($dbObject = $component->dbObject($relation))) {
                $component = $dbObject;
            } elseif ($component instanceof ViewableData && $component->hasField($relation)) {
                $component = $component->obj($relation);
            } else {
                throw new LogicException(
                    "$relation is not a relation/field on " . get_class($component)
                );
            }
        }
        return $component;
    }
public function relObject($fieldPath)
    {
        $object = null;
        $component = $this;

        // Parse all relations
        foreach (explode('.', $fieldPath) as $relation) {
            if (!$component) {
                return null;
            }

            // Inspect relation type
            if (ClassInfo::hasMethod($component, $relation)) {
                $component = $component->$relation();
            } elseif ($component instanceof Relation || $component instanceof DataList) {
                // $relation could either be a field (aggregate), or another relation
                $singleton = DataObject::singleton($component->dataClass());
                $component = $singleton->dbObject($relation) ?: $component->relation($relation);
            } elseif ($component instanceof DataObject && ($dbObject = $component->dbObject($relation))) {
                $component = $dbObject;
            } elseif ($component instanceof ViewableData && $component->hasField($relation)) {
                $component = $component->obj($relation);
            } else {
                throw new LogicException(
                    "$relation is not a relation/field on " . get_class($component)
                );
            }
        }
        return $component;
    }
public function relObject ( $ fieldPath ) { $ object = null ; $ component = $ this ; // Parse all relations foreach ( explode ( '.' , $ fieldPath ) as $ relation ) { if ( ! $ component ) { return null ; } // Inspect relation type if ( ClassInfo :: hasMethod ( $ component , $ relation ) ) { $ component = $ component -> $ relation ( ) ; } elseif ( $ component instanceof Relation || $ component instanceof DataList ) { // $relation could either be a field (aggregate), or another relation $ singleton = DataObject :: singleton ( $ component -> dataClass ( ) ) ; $ component = $ singleton -> dbObject ( $ relation ) ? : $ component -> relation ( $ relation ) ; } elseif ( $ component instanceof DataObject && ( $ dbObject = $ component -> dbObject ( $ relation ) ) ) { $ component = $ dbObject ; } elseif ( $ component instanceof ViewableData && $ component -> hasField ( $ relation ) ) { $ component = $ component -> obj ( $ relation ) ; } else { throw new LogicException ( "$relation is not a relation/field on " . get_class ( $ component ) ) ; } } return $ component ; }
Traverses to a DBField referenced by relationships between data objects.

The path to the related field is specified with dot separated syntax
(eg: Parent.Child.Child.FieldName).

If a relation is blank, this will return null instead.
If a relation name is invalid (e.g. non-relation on a parent) this
can throw a LogicException.

@param string $fieldPath List of paths on this object. All items in this path
must be ViewableData implementors

@return mixed DBField of the field on the object or a DataList instance.
@throws LogicException If accessing invalid relations
Traverses to a DBField referenced by relationships between data objects .