public unassignContentTypeGroup ( eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType, eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup $contentTypeGroup ) | ||
$contentType | eZ\Publish\API\Repository\Values\ContentType\ContentType | |
$contentTypeGroup | eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup |
public function unassignContentTypeGroup(APIContentType $contentType, APIContentTypeGroup $contentTypeGroup)
{
if ($this->repository->hasAccess('class', 'update') !== true) {
throw new UnauthorizedException('ContentType', 'update');
}
$spiContentType = $this->contentTypeHandler->load($contentType->id, $contentType->status);
if (!in_array($contentTypeGroup->id, $spiContentType->groupIds)) {
throw new InvalidArgumentException('$contentTypeGroup', 'The given ContentType is not assigned the ContentTypeGroup');
}
$this->repository->beginTransaction();
try {
$this->contentTypeHandler->unlink($contentTypeGroup->id, $contentType->id, $contentType->status);
$this->repository->commit();
} catch (APIBadStateException $e) {
$this->repository->rollback();
throw new BadStateException('$contentType', 'The given ContentTypeGroup is the last group assigned to the ContentType', $e);
} catch (Exception $e) {
$this->repository->rollback();
throw $e;
}
}