public function removeFieldDefinition(APIContentTypeDraft $contentTypeDraft, APIFieldDefinition $fieldDefinition)
{
if ($this->repository->hasAccess('class', 'update') !== true) {
throw new UnauthorizedException('ContentType', 'update');
}
$loadedFieldDefinition = $this->loadContentTypeDraft($contentTypeDraft->id)->getFieldDefinition($fieldDefinition->identifier);
if (empty($loadedFieldDefinition) || $loadedFieldDefinition->id != $fieldDefinition->id) {
throw new InvalidArgumentException('$fieldDefinition', 'The given FieldDefinition does not belong to the ContentType');
}
$this->repository->beginTransaction();
try {
$this->contentTypeHandler->removeFieldDefinition($contentTypeDraft->id, SPIContentType::STATUS_DRAFT, $fieldDefinition->id);
$this->repository->commit();
} catch (Exception $e) {
$this->repository->rollback();
throw $e;
}
}