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->status !== VersionInfo::STATUS_DRAFT) {
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()}'.");
}