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

    $isOrderRequest = $request->hasValue('referenceOid');
    $request->setValue('role', $request->getValue('relation'));
    if ($isOrderRequest) {
      // change order in a relation
      $request->setValue('containerOid', $request->getValue('sourceOid'));
      $request->setValue('insertOid', $request->getValue('targetOid'));

      // delegate to SortController
      $subResponse = $this->executeSubAction('insertBefore');
    }
    else {
      // update existing object
      // delegate to SaveController
      // NOTE: we need to update first, otherwise the update action might override
      // the foreign keys changes from the associate action
      $subResponse = $this->executeSubAction('update');
      if (!$subResponse->hasErrors()) {
        // and add object to relation
        // delegate to AssociateController
        $subResponse = $this->executeSubAction('associate');
      }
    }

    // add related object to subresponse similar to default update action
    if (!$subResponse->hasErrors()) {
      $targetOidStr = $request->getValue('targetOid');
      $targetOid = ObjectId::parse($targetOidStr);
      $persistenceFacade = $this->getPersistenceFacade();
      $targetObj = $persistenceFacade->load($targetOid);
      $subResponse->setValue('oid', $targetOid);
      $subResponse->setValue($targetOidStr, $targetObj);
    }

    // prevent commit
    if ($subResponse->hasErrors()) {
      $this->endTransaction(false);
    }
    $this->handleSubResponse($subResponse, $targetOidStr);
  }
public function updateInRelation() {
    $this->requireTransaction();
    $request = $this->getRequest();

    $isOrderRequest = $request->hasValue('referenceOid');
    $request->setValue('role', $request->getValue('relation'));
    if ($isOrderRequest) {
      // change order in a relation
      $request->setValue('containerOid', $request->getValue('sourceOid'));
      $request->setValue('insertOid', $request->getValue('targetOid'));

      // delegate to SortController
      $subResponse = $this->executeSubAction('insertBefore');
    }
    else {
      // update existing object
      // delegate to SaveController
      // NOTE: we need to update first, otherwise the update action might override
      // the foreign keys changes from the associate action
      $subResponse = $this->executeSubAction('update');
      if (!$subResponse->hasErrors()) {
        // and add object to relation
        // delegate to AssociateController
        $subResponse = $this->executeSubAction('associate');
      }
    }

    // add related object to subresponse similar to default update action
    if (!$subResponse->hasErrors()) {
      $targetOidStr = $request->getValue('targetOid');
      $targetOid = ObjectId::parse($targetOidStr);
      $persistenceFacade = $this->getPersistenceFacade();
      $targetObj = $persistenceFacade->load($targetOid);
      $subResponse->setValue('oid', $targetOid);
      $subResponse->setValue($targetOidStr, $targetObj);
    }

    // prevent commit
    if ($subResponse->hasErrors()) {
      $this->endTransaction(false);
    }
    $this->handleSubResponse($subResponse, $targetOidStr);
  }
public function updateInRelation ( ) { $ this -> requireTransaction ( ) ; $ request = $ this -> getRequest ( ) ; $ isOrderRequest = $ request -> hasValue ( 'referenceOid' ) ; $ request -> setValue ( 'role' , $ request -> getValue ( 'relation' ) ) ; if ( $ isOrderRequest ) { // change order in a relation $ request -> setValue ( 'containerOid' , $ request -> getValue ( 'sourceOid' ) ) ; $ request -> setValue ( 'insertOid' , $ request -> getValue ( 'targetOid' ) ) ; // delegate to SortController $ subResponse = $ this -> executeSubAction ( 'insertBefore' ) ; } else { // update existing object // delegate to SaveController // NOTE: we need to update first, otherwise the update action might override // the foreign keys changes from the associate action $ subResponse = $ this -> executeSubAction ( 'update' ) ; if ( ! $ subResponse -> hasErrors ( ) ) { // and add object to relation // delegate to AssociateController $ subResponse = $ this -> executeSubAction ( 'associate' ) ; } } // add related object to subresponse similar to default update action if ( ! $ subResponse -> hasErrors ( ) ) { $ targetOidStr = $ request -> getValue ( 'targetOid' ) ; $ targetOid = ObjectId :: parse ( $ targetOidStr ) ; $ persistenceFacade = $ this -> getPersistenceFacade ( ) ; $ targetObj = $ persistenceFacade -> load ( $ targetOid ) ; $ subResponse -> setValue ( 'oid' , $ targetOid ) ; $ subResponse -> setValue ( $ targetOidStr , $ targetObj ) ; } // prevent commit if ( $ subResponse -> hasErrors ( ) ) { $ this -> endTransaction ( false ) ; } $ this -> handleSubResponse ( $ subResponse , $ targetOidStr ) ; }
Update an object in a relation or change the order

| Parameter        | Description
|------------------|-------------------------
| _in_ `language`  | The language of the object
| _in_ `className` | Type of object to update
| _in_ `id`        | Id of object to update
| _in_ `relation`  | Relation name if an existing object should be added to a relation (determines the type of the added object)
| _in_ `sourceId`  | Id of the object to which the added object is related (determines the object id together with _className_)
| _in_ `targetId`  | Id of the object to be added to the relation (determines the object id together with _relation_)
| _out_            | Updated object data

The object data is contained in POST content.
Update an object in a relation or change the order