src/xPDO/Transport/xPDOObjectVehicle.php
protected function _putRelated(& $transport, $alias, & $object, & $payloadElement) {
        if (is_array($payloadElement)) {
            if (is_object($object) && $object instanceof xPDOObject) {
                if (isset ($this->payload['related_object_attributes'][$alias]) && is_array($this->payload['related_object_attributes'][$alias])) {
                    $payloadElement = array_merge($payloadElement, $this->payload['related_object_attributes'][$alias]);
                }
                elseif (isset ($this->payload['related_object_attributes'][$object->_class]) && is_array($this->payload['related_object_attributes'][$object->_class])) {
                    $payloadElement = array_merge($payloadElement, $this->payload['related_object_attributes'][$object->_class]);
                }
                $payloadElement['class'] = $object->_class;
                $nativeKey = $object->getPrimaryKey();
                $payloadElement['object'] = $object->toJSON('', true);
                $payloadElement['guid'] = md5(uniqid(rand(), true));
                $payloadElement['native_key'] = $nativeKey;
                $payloadElement['signature'] = md5($object->_class . '_' . $payloadElement['guid']);
                $relatedObjects = array ();
                foreach ($object->_relatedObjects as $rAlias => $related) {
                    if (is_array($related)) {
                        foreach ($related as $rKey => $rObj) {
                            if (!isset ($relatedObjects[$rAlias]))
                                $relatedObjects[$rAlias] = array ();
                            $guid = md5(uniqid(rand(), true));
                            $relatedObjects[$rAlias][$guid] = array ();
                            $this->_putRelated($transport, $rAlias, $rObj, $relatedObjects[$rAlias][$guid]);
                        }
                    }
                    elseif ($related instanceof xPDOObject) {
                        if (!isset ($relatedObjects[$rAlias]))
                            $relatedObjects[$rAlias] = array ();
                        $guid = md5(uniqid(rand(), true));
                        $relatedObjects[$rAlias][$guid] = array ();
                        $this->_putRelated($transport, $rAlias, $related, $relatedObjects[$rAlias][$guid]);
                    }
                }
                if (!empty ($relatedObjects))
                    $payloadElement['related_objects'] = $relatedObjects;
            }
        }
    }
protected function _putRelated(& $transport, $alias, & $object, & $payloadElement) {
        if (is_array($payloadElement)) {
            if (is_object($object) && $object instanceof xPDOObject) {
                if (isset ($this->payload['related_object_attributes'][$alias]) && is_array($this->payload['related_object_attributes'][$alias])) {
                    $payloadElement = array_merge($payloadElement, $this->payload['related_object_attributes'][$alias]);
                }
                elseif (isset ($this->payload['related_object_attributes'][$object->_class]) && is_array($this->payload['related_object_attributes'][$object->_class])) {
                    $payloadElement = array_merge($payloadElement, $this->payload['related_object_attributes'][$object->_class]);
                }
                $payloadElement['class'] = $object->_class;
                $nativeKey = $object->getPrimaryKey();
                $payloadElement['object'] = $object->toJSON('', true);
                $payloadElement['guid'] = md5(uniqid(rand(), true));
                $payloadElement['native_key'] = $nativeKey;
                $payloadElement['signature'] = md5($object->_class . '_' . $payloadElement['guid']);
                $relatedObjects = array ();
                foreach ($object->_relatedObjects as $rAlias => $related) {
                    if (is_array($related)) {
                        foreach ($related as $rKey => $rObj) {
                            if (!isset ($relatedObjects[$rAlias]))
                                $relatedObjects[$rAlias] = array ();
                            $guid = md5(uniqid(rand(), true));
                            $relatedObjects[$rAlias][$guid] = array ();
                            $this->_putRelated($transport, $rAlias, $rObj, $relatedObjects[$rAlias][$guid]);
                        }
                    }
                    elseif ($related instanceof xPDOObject) {
                        if (!isset ($relatedObjects[$rAlias]))
                            $relatedObjects[$rAlias] = array ();
                        $guid = md5(uniqid(rand(), true));
                        $relatedObjects[$rAlias][$guid] = array ();
                        $this->_putRelated($transport, $rAlias, $related, $relatedObjects[$rAlias][$guid]);
                    }
                }
                if (!empty ($relatedObjects))
                    $payloadElement['related_objects'] = $relatedObjects;
            }
        }
    }
protected function _putRelated ( & $ transport , $ alias , & $ object , & $ payloadElement ) { if ( is_array ( $ payloadElement ) ) { if ( is_object ( $ object ) && $ object instanceof xPDOObject ) { if ( isset ( $ this -> payload [ 'related_object_attributes' ] [ $ alias ] ) && is_array ( $ this -> payload [ 'related_object_attributes' ] [ $ alias ] ) ) { $ payloadElement = array_merge ( $ payloadElement , $ this -> payload [ 'related_object_attributes' ] [ $ alias ] ) ; } elseif ( isset ( $ this -> payload [ 'related_object_attributes' ] [ $ object -> _class ] ) && is_array ( $ this -> payload [ 'related_object_attributes' ] [ $ object -> _class ] ) ) { $ payloadElement = array_merge ( $ payloadElement , $ this -> payload [ 'related_object_attributes' ] [ $ object -> _class ] ) ; } $ payloadElement [ 'class' ] = $ object -> _class ; $ nativeKey = $ object -> getPrimaryKey ( ) ; $ payloadElement [ 'object' ] = $ object -> toJSON ( '' , true ) ; $ payloadElement [ 'guid' ] = md5 ( uniqid ( rand ( ) , true ) ) ; $ payloadElement [ 'native_key' ] = $ nativeKey ; $ payloadElement [ 'signature' ] = md5 ( $ object -> _class . '_' . $ payloadElement [ 'guid' ] ) ; $ relatedObjects = array ( ) ; foreach ( $ object -> _relatedObjects as $ rAlias => $ related ) { if ( is_array ( $ related ) ) { foreach ( $ related as $ rKey => $ rObj ) { if ( ! isset ( $ relatedObjects [ $ rAlias ] ) ) $ relatedObjects [ $ rAlias ] = array ( ) ; $ guid = md5 ( uniqid ( rand ( ) , true ) ) ; $ relatedObjects [ $ rAlias ] [ $ guid ] = array ( ) ; $ this -> _putRelated ( $ transport , $ rAlias , $ rObj , $ relatedObjects [ $ rAlias ] [ $ guid ] ) ; } } elseif ( $ related instanceof xPDOObject ) { if ( ! isset ( $ relatedObjects [ $ rAlias ] ) ) $ relatedObjects [ $ rAlias ] = array ( ) ; $ guid = md5 ( uniqid ( rand ( ) , true ) ) ; $ relatedObjects [ $ rAlias ] [ $ guid ] = array ( ) ; $ this -> _putRelated ( $ transport , $ rAlias , $ related , $ relatedObjects [ $ rAlias ] [ $ guid ] ) ; } } if ( ! empty ( $ relatedObjects ) ) $ payloadElement [ 'related_objects' ] = $ relatedObjects ; } } }
Recursively put related objects into the vehicle.

@access protected
@param xPDOTransport $transport The host xPDOTransport instance.
@param string $alias The alias representing the relation to the parent object.
@param xPDOObject &$object A reference to the dependent object being added into the vehicle.
@param array $payloadElement An element of the payload to place the dependent object in.
Recursively put related objects into the vehicle .