lib/components/dataInterface/DataItem.php
public function handle($fromRelative = false, $baseAttributes = [])
    {
        $this->baseAttributes = $baseAttributes;
        if ($this->handledDataItem) {
            if ($this->isForeign) {
                $object = $this->localObject;
            } else {
                $object = $this->foreignObject;
            }
            if (!empty($baseAttributes)) {
                foreach ($baseAttributes as $key => $value) {
                    $object->{$key} = $value;
                }
                if (!$object->save()) {
                    return false;
                }
            }

            return $object;
        }
        if ($fromRelative || !$this->dataSource->childOnly) {
            if (isset($baseAttributes['relationModels'][0]['parent_object_id'])) {
                $baseAttributes['indirectObject'] = $baseAttributes['relationModels'][0]['parent_object_id'];
            }
            if ($this->isForeign) {
                // handle local to foreign
                $result = $this->handler->handleForeign($baseAttributes);
            } else {
                $result = $this->handler->handleLocal($baseAttributes);
            }
        } else {
            $result = true;
        }
        if (is_null($result)) {
            $this->handledDataItem = true;
        } elseif ($result) {
            if (is_object($result)) {
                $this->handledDataItem = true;
            }
            if ($this->dataSource->postProcess) {
                call_user_func($this->dataSource->postProcess, $this);
            }

            return $result;
        }

        return false;
    }
public function handle($fromRelative = false, $baseAttributes = [])
    {
        $this->baseAttributes = $baseAttributes;
        if ($this->handledDataItem) {
            if ($this->isForeign) {
                $object = $this->localObject;
            } else {
                $object = $this->foreignObject;
            }
            if (!empty($baseAttributes)) {
                foreach ($baseAttributes as $key => $value) {
                    $object->{$key} = $value;
                }
                if (!$object->save()) {
                    return false;
                }
            }

            return $object;
        }
        if ($fromRelative || !$this->dataSource->childOnly) {
            if (isset($baseAttributes['relationModels'][0]['parent_object_id'])) {
                $baseAttributes['indirectObject'] = $baseAttributes['relationModels'][0]['parent_object_id'];
            }
            if ($this->isForeign) {
                // handle local to foreign
                $result = $this->handler->handleForeign($baseAttributes);
            } else {
                $result = $this->handler->handleLocal($baseAttributes);
            }
        } else {
            $result = true;
        }
        if (is_null($result)) {
            $this->handledDataItem = true;
        } elseif ($result) {
            if (is_object($result)) {
                $this->handledDataItem = true;
            }
            if ($this->dataSource->postProcess) {
                call_user_func($this->dataSource->postProcess, $this);
            }

            return $result;
        }

        return false;
    }
[[@doctodo method_description:handle]].

@param boolean $fromRelative   [[@doctodo param_description:fromRelative]] [optional]
@param array   $baseAttributes [[@doctodo param_description:baseAttributes]] [optional]

@return [[@doctodo return_type:handle]] [[@doctodo return_description:handle]]