/** * @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; }
/** * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If type is defined and still has content * * @param mixed $contentTypeId * @param int $status * * @return bool */ public function delete($contentTypeId, $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; }
/** * Deletes a Type completely. * * @param mixed $typeId * @param int $status */ public function delete($typeId, $status) { try { return $this->innerGateway->delete($typeId, $status); } catch (DBALException $e) { throw new RuntimeException('Database error', 0, $e); } catch (PDOException $e) { throw new RuntimeException('Database error', 0, $e); } }
/** * Deletes $fromType and all of its field definitions * * @param \eZ\Publish\SPI\Persistence\Content\Type $fromType * * @return void */ public function deleteOldType(Type $fromType) { $this->contentTypeGateway->delete($fromType->id, $fromType->status); }