library/Garp/Content/Api/Rest.php
protected function _getRelatedResults(array $params) {
        // Check for existence of the subject record first, in order to return a 404 error
        list($subjectRecord, $httpCode) = $this->_getSingleResult($params);
        if (!$subjectRecord['success']) {
            return array(
                array(
                    'success' => false,
                    'result' => array()
                ),
                404
            );
        }

        $schema = new Garp_Content_Api_Rest_Schema('rest');
        $relation = $schema->getRelation($params['datatype'], $params['relatedType']);
        list($rule1, $rule2) = $relation->getRules($params['datatype']);

        $contentManager = $this->_getContentManager($relation->model);
        $subjectId = $params['id'];
        unset($params['id']);
        $options = $this->_extractOptionsForFetch($params);
        $options['query'][ucfirst($params['datatype']) . '.id'] = $subjectId;
        $options['bindingModel'] = $relation->getBindingModel()->id;
        $options['rule'] = $rule1;
        $options['rule2'] = $rule2;
        $options['fields'] = Zend_Db_Select::SQL_WILDCARD;

        if ($contentManager->getModel()->isMultilingual()) {
            $options['joinMultilingualModel'] = true;
        }
        $records = $contentManager->fetch($options);
        $amount = count($records);
        $records = array($params['relatedType'] => $records);
        if (isset($options['with'])) {
            $records = $this->_combineRecords($params['relatedType'], $records, $options['with']);
        }
        return array(
            array(
                'success' => true,
                'result' => $records,
                'amount' => $amount,
                'total' => intval($contentManager->count($options))
            ),
            200
        );
    }
protected function _getRelatedResults(array $params) {
        // Check for existence of the subject record first, in order to return a 404 error
        list($subjectRecord, $httpCode) = $this->_getSingleResult($params);
        if (!$subjectRecord['success']) {
            return array(
                array(
                    'success' => false,
                    'result' => array()
                ),
                404
            );
        }

        $schema = new Garp_Content_Api_Rest_Schema('rest');
        $relation = $schema->getRelation($params['datatype'], $params['relatedType']);
        list($rule1, $rule2) = $relation->getRules($params['datatype']);

        $contentManager = $this->_getContentManager($relation->model);
        $subjectId = $params['id'];
        unset($params['id']);
        $options = $this->_extractOptionsForFetch($params);
        $options['query'][ucfirst($params['datatype']) . '.id'] = $subjectId;
        $options['bindingModel'] = $relation->getBindingModel()->id;
        $options['rule'] = $rule1;
        $options['rule2'] = $rule2;
        $options['fields'] = Zend_Db_Select::SQL_WILDCARD;

        if ($contentManager->getModel()->isMultilingual()) {
            $options['joinMultilingualModel'] = true;
        }
        $records = $contentManager->fetch($options);
        $amount = count($records);
        $records = array($params['relatedType'] => $records);
        if (isset($options['with'])) {
            $records = $this->_combineRecords($params['relatedType'], $records, $options['with']);
        }
        return array(
            array(
                'success' => true,
                'result' => $records,
                'amount' => $amount,
                'total' => intval($contentManager->count($options))
            ),
            200
        );
    }
protected function _getRelatedResults ( array $ params ) { // Check for existence of the subject record first, in order to return a 404 error list ( $ subjectRecord , $ httpCode ) = $ this -> _getSingleResult ( $ params ) ; if ( ! $ subjectRecord [ 'success' ] ) { return array ( array ( 'success' => false , 'result' => array ( ) ) , 404 ) ; } $ schema = new Garp_Content_Api_Rest_Schema ( 'rest' ) ; $ relation = $ schema -> getRelation ( $ params [ 'datatype' ] , $ params [ 'relatedType' ] ) ; list ( $ rule1 , $ rule2 ) = $ relation -> getRules ( $ params [ 'datatype' ] ) ; $ contentManager = $ this -> _getContentManager ( $ relation -> model ) ; $ subjectId = $ params [ 'id' ] ; unset ( $ params [ 'id' ] ) ; $ options = $ this -> _extractOptionsForFetch ( $ params ) ; $ options [ 'query' ] [ ucfirst ( $ params [ 'datatype' ] ) . '.id' ] = $ subjectId ; $ options [ 'bindingModel' ] = $ relation -> getBindingModel ( ) -> id ; $ options [ 'rule' ] = $ rule1 ; $ options [ 'rule2' ] = $ rule2 ; $ options [ 'fields' ] = Zend_Db_Select :: SQL_WILDCARD ; if ( $ contentManager -> getModel ( ) -> isMultilingual ( ) ) { $ options [ 'joinMultilingualModel' ] = true ; } $ records = $ contentManager -> fetch ( $ options ) ; $ amount = count ( $ records ) ; $ records = array ( $ params [ 'relatedType' ] => $ records ) ; if ( isset ( $ options [ 'with' ] ) ) { $ records = $ this -> _combineRecords ( $ params [ 'relatedType' ] , $ records , $ options [ 'with' ] ) ; } return array ( array ( 'success' => true , 'result' => $ records , 'amount' => $ amount , 'total' => intval ( $ contentManager -> count ( $ options ) ) ) , 200 ) ; }
Get index of items related to the given id.

@param array $params
@return array
Get index of items related to the given id .