/**
* @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 )
{
if ( !$this->contentTypeGateway->loadTypeData( $contentTypeId, $status ) )
{
throw new NotFoundException(
"ContentType",
array(
"id" => $contentTypeId,
"status" => $status
)
);
}
if ( Type::STATUS_DEFINED === $status && $this->contentTypeGateway->countInstancesOfType( $contentTypeId ) )
{
throw new BadStateException(
"\$contentTypeId",
"ContentType with given id still has content instances and therefore can't be deleted"
);
}
$this->contentTypeGateway->delete(
$contentTypeId, $status
);
// @todo FIXME: Return true only if deletion happened
return true;
}