src/wcmf/application/controller/RESTController.php
public function readInRelation() {
    $request = $this->getRequest();

    // rewrite query if querying for a relation
    $relationName = $request->getValue('relation');

    // set the query
    $sourceOid = ObjectId::parse($request->getValue('sourceOid'));
    $persistenceFacade = $this->getPersistenceFacade();
    $sourceNode = $persistenceFacade->load($sourceOid);
    if ($sourceNode) {
      $relationQuery = NodeUtil::getRelationQueryCondition($sourceNode, $relationName);
      $query = ($request->hasValue('query') ? $request->getValue('query').'&' : '').$relationQuery;
      $request->setValue('query', $query);

      // set the class name
      $mapper = $sourceNode->getMapper();
      $relation = $mapper->getRelation($relationName);
      $otherType = $relation->getOtherType();
      $request->setValue('className', $otherType);

      // set default order
      if (!$request->hasValue('sortFieldName')) {
        $otherMapper = $persistenceFacade->getMapper($otherType);
        $sortkeyDef = $otherMapper->getSortkey($relation->getThisRole());
        if ($sortkeyDef != null) {
          $request->setValue('sortFieldName', $sortkeyDef['sortFieldName']);
          $request->setValue('sortDirection', $sortkeyDef['sortDirection']);
        }
      }
    }

    // delegate to ListController
    $subResponse = $this->executeSubAction('list');
    $this->handleSubResponse($subResponse);
  }
public function readInRelation() {
    $request = $this->getRequest();

    // rewrite query if querying for a relation
    $relationName = $request->getValue('relation');

    // set the query
    $sourceOid = ObjectId::parse($request->getValue('sourceOid'));
    $persistenceFacade = $this->getPersistenceFacade();
    $sourceNode = $persistenceFacade->load($sourceOid);
    if ($sourceNode) {
      $relationQuery = NodeUtil::getRelationQueryCondition($sourceNode, $relationName);
      $query = ($request->hasValue('query') ? $request->getValue('query').'&' : '').$relationQuery;
      $request->setValue('query', $query);

      // set the class name
      $mapper = $sourceNode->getMapper();
      $relation = $mapper->getRelation($relationName);
      $otherType = $relation->getOtherType();
      $request->setValue('className', $otherType);

      // set default order
      if (!$request->hasValue('sortFieldName')) {
        $otherMapper = $persistenceFacade->getMapper($otherType);
        $sortkeyDef = $otherMapper->getSortkey($relation->getThisRole());
        if ($sortkeyDef != null) {
          $request->setValue('sortFieldName', $sortkeyDef['sortFieldName']);
          $request->setValue('sortDirection', $sortkeyDef['sortDirection']);
        }
      }
    }

    // delegate to ListController
    $subResponse = $this->executeSubAction('list');
    $this->handleSubResponse($subResponse);
  }
public function readInRelation ( ) { $ request = $ this -> getRequest ( ) ; // rewrite query if querying for a relation $ relationName = $ request -> getValue ( 'relation' ) ; // set the query $ sourceOid = ObjectId :: parse ( $ request -> getValue ( 'sourceOid' ) ) ; $ persistenceFacade = $ this -> getPersistenceFacade ( ) ; $ sourceNode = $ persistenceFacade -> load ( $ sourceOid ) ; if ( $ sourceNode ) { $ relationQuery = NodeUtil :: getRelationQueryCondition ( $ sourceNode , $ relationName ) ; $ query = ( $ request -> hasValue ( 'query' ) ? $ request -> getValue ( 'query' ) . '&' : '' ) . $ relationQuery ; $ request -> setValue ( 'query' , $ query ) ; // set the class name $ mapper = $ sourceNode -> getMapper ( ) ; $ relation = $ mapper -> getRelation ( $ relationName ) ; $ otherType = $ relation -> getOtherType ( ) ; $ request -> setValue ( 'className' , $ otherType ) ; // set default order if ( ! $ request -> hasValue ( 'sortFieldName' ) ) { $ otherMapper = $ persistenceFacade -> getMapper ( $ otherType ) ; $ sortkeyDef = $ otherMapper -> getSortkey ( $ relation -> getThisRole ( ) ) ; if ( $ sortkeyDef != null ) { $ request -> setValue ( 'sortFieldName' , $ sortkeyDef [ 'sortFieldName' ] ) ; $ request -> setValue ( 'sortDirection' , $ sortkeyDef [ 'sortDirection' ] ) ; } } } // delegate to ListController $ subResponse = $ this -> executeSubAction ( 'list' ) ; $ this -> handleSubResponse ( $ subResponse ) ; }
Read objects that are related to another object

| Parameter        | Description
|------------------|-------------------------
| _in_ `language`  | The language of the returned objects
| _in_ `sourceId`  | Id of the object to which the returned objects are related (determines the object id together with _className_)
| _in_ `className` | The type of the object defined by _sourceId_
| _in_ `relation`  | Name of the relation to the object defined by _sourceId_ (determines the type of the returned objects)
| _in_ `sortBy`    | <em>?sortBy=+foo</em> for sorting the list by foo ascending or
| _in_ `sort`      | <em>?sort(+foo)</em> for sorting the list by foo ascending
| _in_ `limit`     | <em>?limit(10,25)</em> for loading 10 objects starting from position 25
| _in_ `query`     | A query condition encoded in RQL to be used with StringQuery::setRQLConditionString()
| _out_            | List of objects
Read objects that are related to another object