public function removeRelation($contentId, $versionNumber, $relationId, Request $request)
    {
        $versionInfo = $this->repository->getContentService()->loadVersionInfo(
            $this->repository->getContentService()->loadContentInfo($contentId),
            $versionNumber
        );

        $versionRelations = $this->repository->getContentService()->loadRelations($versionInfo);
        foreach ($versionRelations as $relation) {
            if ($relation->id == $relationId) {
                if ($relation->type !== Relation::COMMON) {
                    throw new ForbiddenException('Relation is not of type COMMON');
                }

                if (!$versionInfo->isDraft()) {
                    throw new ForbiddenException('Relation of type COMMON can only be removed from drafts');
                }

                $this->repository->getContentService()->deleteRelation($versionInfo, $relation->getDestinationContentInfo());

                return new Values\NoContent();
            }
        }

        throw new Exceptions\NotFoundException("Relation not found: '{$request->getPathInfo()}'.");
    }
public function removeRelation($contentId, $versionNumber, $relationId, Request $request)
    {
        $versionInfo = $this->repository->getContentService()->loadVersionInfo(
            $this->repository->getContentService()->loadContentInfo($contentId),
            $versionNumber
        );

        $versionRelations = $this->repository->getContentService()->loadRelations($versionInfo);
        foreach ($versionRelations as $relation) {
            if ($relation->id == $relationId) {
                if ($relation->type !== Relation::COMMON) {
                    throw new ForbiddenException('Relation is not of type COMMON');
                }

                if (!$versionInfo->isDraft()) {
                    throw new ForbiddenException('Relation of type COMMON can only be removed from drafts');
                }

                $this->repository->getContentService()->deleteRelation($versionInfo, $relation->getDestinationContentInfo());

                return new Values\NoContent();
            }
        }

        throw new Exceptions\NotFoundException("Relation not found: '{$request->getPathInfo()}'.");
    }
public function removeRelation ( $ contentId , $ versionNumber , $ relationId , Request $ request ) { $ versionInfo = $ this -> repository -> getContentService ( ) -> loadVersionInfo ( $ this -> repository -> getContentService ( ) -> loadContentInfo ( $ contentId ) , $ versionNumber ) ; $ versionRelations = $ this -> repository -> getContentService ( ) -> loadRelations ( $ versionInfo ) ; foreach ( $ versionRelations as $ relation ) { if ( $ relation -> id == $ relationId ) { if ( $ relation -> type !== Relation :: COMMON ) { throw new ForbiddenException ( 'Relation is not of type COMMON' ) ; } if ( ! $ versionInfo -> isDraft ( ) ) { throw new ForbiddenException ( 'Relation of type COMMON can only be removed from drafts' ) ; } $ this -> repository -> getContentService ( ) -> deleteRelation ( $ versionInfo , $ relation -> getDestinationContentInfo ( ) ) ; return new Values \ NoContent ( ) ; } } throw new Exceptions \ NotFoundException ( "Relation not found: '{$request->getPathInfo()}'." ) ; }
Deletes a relation of the given draft.

@param mixed $contentId
@param int   $versionNumber
@param mixed $relationId

@throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException
@throws \eZ\Publish\Core\REST\Common\Exceptions\NotFoundException

@return \eZ\Publish\Core\REST\Server\Values\NoContent
Deletes a relation of the given draft .