/** * Delete a Content Type object. * * Deletes a content type if it has no instances * * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If there exist content objects of this type * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to delete a content type * * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType */ public function deleteContentType(APIContentType $contentType) { if ($this->repository->hasAccess('class', 'delete') !== true) { throw new UnauthorizedException('ContentType', 'delete'); } $this->repository->beginTransaction(); try { $this->contentTypeHandler->delete($contentType->id, $contentType->status); $this->repository->commit(); } catch (Exception $e) { $this->repository->rollback(); throw $e; } }
/** * Delete a Content Type object. * * Deletes a content type if it has no instances. If content type in state STATUS_DRAFT is * given, only the draft content type will be deleted. Otherwise, if content type in state * STATUS_DEFINED is given, all content type data will be deleted. * * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If there exist content objects of this type * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to delete a content type * * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType */ public function deleteContentType(APIContentType $contentType) { if ($this->repository->hasAccess('class', 'delete') !== true) { throw new UnauthorizedException('ContentType', 'delete'); } $this->repository->beginTransaction(); try { if (!$contentType instanceof APIContentTypeDraft) { $this->contentTypeHandler->delete($contentType->id, APIContentTypeDraft::STATUS_DEFINED); } $this->contentTypeHandler->delete($contentType->id, APIContentTypeDraft::STATUS_DRAFT); $this->repository->commit(); } catch (Exception $e) { $this->repository->rollback(); throw $e; } }
/** * * * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If type is defined and still has content * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If type is not found * * @param mixed $contentTypeId * @param int $status * * @return boolean */ public function delete($contentTypeId, $status) { $this->clearCache(); return $this->innerHandler->delete($contentTypeId, $status); }