/** * Delete a Content Type Group. * * This method only deletes an content type group which has content types without any content instances * * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to delete a content type group * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If a to be deleted content type has instances * * @param \eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup $contentTypeGroup */ public function deleteContentTypeGroup( APIContentTypeGroup $contentTypeGroup ) { if ( $this->repository->hasAccess( 'class', 'delete' ) !== true ) throw new UnauthorizedException( 'ContentType', 'delete' ); $loadedContentTypeGroup = $this->loadContentTypeGroup( $contentTypeGroup->id ); $this->repository->beginTransaction(); try { $this->contentTypeHandler->deleteGroup( $loadedContentTypeGroup->id ); $this->repository->commit(); } catch ( APIBadStateException $e ) { $this->repository->rollback(); throw new InvalidArgumentException( "\$contentTypeGroup", "Content type group has content type instances", $e ); } catch ( Exception $e ) { $this->repository->rollback(); throw $e; } }
/** * @param mixed $groupId * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If type group contains types * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If type group with id is not found */ public function deleteGroup($groupId) { $this->clearCache(); return $this->innerHandler->deleteGroup($groupId); }