lib/components/dataInterface/connectors/generic/DataSource.php
public function updateLocalObject($relatedType, $valueMap, $fieldMap, $localModel)
    {
        $localModelClass = $relatedType->primaryModel;
        // @todo eventually we'll probably take some keys out of this
        $searchMap = $valueMap;
        if (isset($fieldMap->searchFields) && is_array($fieldMap->searchFields)) {
            foreach ($searchMap as $field => $value) {
                if (!in_array($field, $fieldMap->searchFields)) {
                    unset($searchMap[$field]);
                }
            }
        }
        $fieldParts = explode(':', $fieldMap->localField);
        if ($fieldParts[0] === 'child') {
            $currentRelationsFunction = 'child';
        } else {
            $currentRelationsFunction = 'parent';
        }
        // first, lets see if it exists
        $relatedObject = null;
        $currentRelation = false;
        if (!empty($localModel) && !$localModel->isNewRecord) {
            $test = $localModel->{$currentRelationsFunction}($relatedType->primaryModel, [], ['where' => $searchMap, 'disableAccessCheck' => 1]);
            if ($test) {
                $relatedObject = $test;
                $currentRelation = true;
            }
        }

        if (empty($relatedObject)) {
            $relatedClass = $relatedType->primaryModel;
            $relatedObject = new $relatedClass();
        }
        $relatedObject->auditDataInterface = $this->module->collectorItem->interfaceObject->primaryKey;
        $relatedObject->attributes = $valueMap;
        if ($relatedObject->save()) {
            return $relatedObject;
        } else {
            $errors = $relatedObject->errors;
            foreach ($fieldMap->mute as $mute) {
                unset($errors[$mute]);
            }
            if (!empty($errors)) {
                \d($relatedObject->attributes);
                \d($errors);
                exit;
            }

            return false;
        }
    }
public function updateLocalObject($relatedType, $valueMap, $fieldMap, $localModel)
    {
        $localModelClass = $relatedType->primaryModel;
        // @todo eventually we'll probably take some keys out of this
        $searchMap = $valueMap;
        if (isset($fieldMap->searchFields) && is_array($fieldMap->searchFields)) {
            foreach ($searchMap as $field => $value) {
                if (!in_array($field, $fieldMap->searchFields)) {
                    unset($searchMap[$field]);
                }
            }
        }
        $fieldParts = explode(':', $fieldMap->localField);
        if ($fieldParts[0] === 'child') {
            $currentRelationsFunction = 'child';
        } else {
            $currentRelationsFunction = 'parent';
        }
        // first, lets see if it exists
        $relatedObject = null;
        $currentRelation = false;
        if (!empty($localModel) && !$localModel->isNewRecord) {
            $test = $localModel->{$currentRelationsFunction}($relatedType->primaryModel, [], ['where' => $searchMap, 'disableAccessCheck' => 1]);
            if ($test) {
                $relatedObject = $test;
                $currentRelation = true;
            }
        }

        if (empty($relatedObject)) {
            $relatedClass = $relatedType->primaryModel;
            $relatedObject = new $relatedClass();
        }
        $relatedObject->auditDataInterface = $this->module->collectorItem->interfaceObject->primaryKey;
        $relatedObject->attributes = $valueMap;
        if ($relatedObject->save()) {
            return $relatedObject;
        } else {
            $errors = $relatedObject->errors;
            foreach ($fieldMap->mute as $mute) {
                unset($errors[$mute]);
            }
            if (!empty($errors)) {
                \d($relatedObject->attributes);
                \d($errors);
                exit;
            }

            return false;
        }
    }
public function updateLocalObject ( $ relatedType , $ valueMap , $ fieldMap , $ localModel ) { $ localModelClass = $ relatedType -> primaryModel ; // @todo eventually we'll probably take some keys out of this $ searchMap = $ valueMap ; if ( isset ( $ fieldMap -> searchFields ) && is_array ( $ fieldMap -> searchFields ) ) { foreach ( $ searchMap as $ field => $ value ) { if ( ! in_array ( $ field , $ fieldMap -> searchFields ) ) { unset ( $ searchMap [ $ field ] ) ; } } } $ fieldParts = explode ( ':' , $ fieldMap -> localField ) ; if ( $ fieldParts [ 0 ] === 'child' ) { $ currentRelationsFunction = 'child' ; } else { $ currentRelationsFunction = 'parent' ; } // first, lets see if it exists $ relatedObject = null ; $ currentRelation = false ; if ( ! empty ( $ localModel ) && ! $ localModel -> isNewRecord ) { $ test = $ localModel -> { $ currentRelationsFunction } ( $ relatedType -> primaryModel , [ ] , [ 'where' => $ searchMap , 'disableAccessCheck' => 1 ] ) ; if ( $ test ) { $ relatedObject = $ test ; $ currentRelation = true ; } } if ( empty ( $ relatedObject ) ) { $ relatedClass = $ relatedType -> primaryModel ; $ relatedObject = new $ relatedClass ( ) ; } $ relatedObject -> auditDataInterface = $ this -> module -> collectorItem -> interfaceObject -> primaryKey ; $ relatedObject -> attributes = $ valueMap ; if ( $ relatedObject -> save ( ) ) { return $ relatedObject ; } else { $ errors = $ relatedObject -> errors ; foreach ( $ fieldMap -> mute as $ mute ) { unset ( $ errors [ $ mute ] ) ; } if ( ! empty ( $ errors ) ) { \ d ( $ relatedObject -> attributes ) ; \ d ( $ errors ) ; exit ; } return false ; } }
[[@doctodo method_description:updateLocalObject]].

@param [[@doctodo param_type:relatedType]] $relatedType [[@doctodo param_description:relatedType]]
@param [[@doctodo param_type:valueMap]]    $valueMap    [[@doctodo param_description:valueMap]]
@param [[@doctodo param_type:fieldMap]]    $fieldMap    [[@doctodo param_description:fieldMap]]
@param [[@doctodo param_type:localModel]]  $localModel  [[@doctodo param_description:localModel]]

@throws \Exception [[@doctodo exception_description:\Exception]]
@return [[@doctodo return_type:updateLocalObject]] [[@doctodo return_description:updateLocalObject]]
[[ @doctodo method_description : updateLocalObject ]] .