Beispiel #1
0
 /**
  * Deletes $tag and all its descendants and synonyms.
  *
  * If $tag is a synonym, only the synonym is deleted
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to delete this tag
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified tag is not found
  *
  * @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
  */
 public function deleteTag(Tag $tag)
 {
     if ($tag->mainTagId > 0) {
         if ($this->hasAccess('tags', 'deletesynonym') !== true) {
             throw new UnauthorizedException('tags', 'deletesynonym');
         }
     } else {
         if ($this->hasAccess('tags', 'delete') !== true) {
             throw new UnauthorizedException('tags', 'delete');
         }
     }
     $this->repository->beginTransaction();
     try {
         $this->tagsHandler->deleteTag($tag->id);
         $this->repository->commit();
     } catch (Exception $e) {
         $this->repository->rollback();
         throw $e;
     }
 }