public function deleteVersion(APIVersionInfo $versionInfo)
{
if ($versionInfo->status === APIVersionInfo::STATUS_PUBLISHED) {
throw new BadStateException('$versionInfo', 'Version is published and can not be removed');
}
if (!$this->repository->canUser('content', 'versionremove', $versionInfo)) {
throw new UnauthorizedException('content', 'versionremove', array('contentId' => $versionInfo->contentInfo->id, 'versionNo' => $versionInfo->versionNo));
}
$versionList = $this->persistenceHandler->contentHandler()->listVersions($versionInfo->contentInfo->id);
if (count($versionList) === 1) {
throw new BadStateException('$versionInfo', 'Version is the last version of the Content and can not be removed');
}
$this->repository->beginTransaction();
try {
$this->persistenceHandler->contentHandler()->deleteVersion($versionInfo->getContentInfo()->id, $versionInfo->versionNo);
$this->repository->commit();
} catch (Exception $e) {
$this->repository->rollback();
throw $e;
}
}