library/Garp/Content/Api/Rest.php
public function put(array $params, array $postData) {
        $this->_requireDataType($params);
        if (!array_get($params, 'id')) {
            throw new Garp_Content_Api_Rest_Exception(
                self::EXCEPTION_PUT_WITHOUT_ID
            );
        }
        $model = $this->_normalizeModelName($params['datatype']);

        // First, see if the record actually exists
        list($record) = $this->_getSingleResult($params);
        if (is_null($record['result'])) {
            return $this->_formatResponse(array('success' => false), 404);
        }

        if (!array_get($params, 'relatedType')) {
            $this->_updateSingle($params, $postData);
            list($response, $httpCode) = $this->_getSingleResult($params);
        } else {
            $schema = new Garp_Content_Api_Rest_Schema('rest');
            // Sanity check if related model exists
            list($relatedRecord) = $this->_getSingleResult(
                array(
                    'datatype' => getProperty(
                        'model',
                        $schema->getRelation(
                            $params['datatype'],
                            $params['relatedType']
                        )
                    ),
                    'id' => $params['relatedId']
                )
            );
            if (!$relatedRecord['result']) {
                return $this->_formatResponse(array('success' => false), 404);
            }

            $this->_addRelation($params, $postData);
            list($response, $httpCode) = $this->_getRelatedResults($params);
        }
        return $this->_formatResponse($response, $httpCode);
    }
public function put(array $params, array $postData) {
        $this->_requireDataType($params);
        if (!array_get($params, 'id')) {
            throw new Garp_Content_Api_Rest_Exception(
                self::EXCEPTION_PUT_WITHOUT_ID
            );
        }
        $model = $this->_normalizeModelName($params['datatype']);

        // First, see if the record actually exists
        list($record) = $this->_getSingleResult($params);
        if (is_null($record['result'])) {
            return $this->_formatResponse(array('success' => false), 404);
        }

        if (!array_get($params, 'relatedType')) {
            $this->_updateSingle($params, $postData);
            list($response, $httpCode) = $this->_getSingleResult($params);
        } else {
            $schema = new Garp_Content_Api_Rest_Schema('rest');
            // Sanity check if related model exists
            list($relatedRecord) = $this->_getSingleResult(
                array(
                    'datatype' => getProperty(
                        'model',
                        $schema->getRelation(
                            $params['datatype'],
                            $params['relatedType']
                        )
                    ),
                    'id' => $params['relatedId']
                )
            );
            if (!$relatedRecord['result']) {
                return $this->_formatResponse(array('success' => false), 404);
            }

            $this->_addRelation($params, $postData);
            list($response, $httpCode) = $this->_getRelatedResults($params);
        }
        return $this->_formatResponse($response, $httpCode);
    }
public function put ( array $ params , array $ postData ) { $ this -> _requireDataType ( $ params ) ; if ( ! array_get ( $ params , 'id' ) ) { throw new Garp_Content_Api_Rest_Exception ( self :: EXCEPTION_PUT_WITHOUT_ID ) ; } $ model = $ this -> _normalizeModelName ( $ params [ 'datatype' ] ) ; // First, see if the record actually exists list ( $ record ) = $ this -> _getSingleResult ( $ params ) ; if ( is_null ( $ record [ 'result' ] ) ) { return $ this -> _formatResponse ( array ( 'success' => false ) , 404 ) ; } if ( ! array_get ( $ params , 'relatedType' ) ) { $ this -> _updateSingle ( $ params , $ postData ) ; list ( $ response , $ httpCode ) = $ this -> _getSingleResult ( $ params ) ; } else { $ schema = new Garp_Content_Api_Rest_Schema ( 'rest' ) ; // Sanity check if related model exists list ( $ relatedRecord ) = $ this -> _getSingleResult ( array ( 'datatype' => getProperty ( 'model' , $ schema -> getRelation ( $ params [ 'datatype' ] , $ params [ 'relatedType' ] ) ) , 'id' => $ params [ 'relatedId' ] ) ) ; if ( ! $ relatedRecord [ 'result' ] ) { return $ this -> _formatResponse ( array ( 'success' => false ) , 404 ) ; } $ this -> _addRelation ( $ params , $ postData ) ; list ( $ response , $ httpCode ) = $ this -> _getRelatedResults ( $ params ) ; } return $ this -> _formatResponse ( $ response , $ httpCode ) ; }
PUT changes into an existing record

@param array $params
@param array $postData
@return array
PUT changes into an existing record