Beispiel #1
0
 public function delete()
 {
     try {
         $this->tagManager->deleteTags($this->tag->getId());
     } catch (TagNotFoundException $e) {
         // can happen if concurrent deletion occurred
         throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e);
     }
 }
 public function testDeleteTagRemovesRelations()
 {
     $tag1 = $this->tagManager->createTag('one', true, false);
     $tag2 = $this->tagManager->createTag('two', true, true);
     $tagMapper = new SystemTagObjectMapper($this->connection, $this->tagManager);
     $tagMapper->assignTags(1, 'testtype', $tag1->getId());
     $tagMapper->assignTags(1, 'testtype', $tag2->getId());
     $tagMapper->assignTags(2, 'testtype', $tag1->getId());
     $this->tagManager->deleteTags($tag1->getId());
     $tagIdMapping = $tagMapper->getTagIdsForObjects([1, 2], 'testtype');
     $this->assertEquals([1 => [$tag2->getId()], 2 => []], $tagIdMapping);
 }
 public function delete()
 {
     try {
         if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) {
             throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found');
         }
         if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) {
             throw new Forbidden('No permission to delete tag ' . $this->tag->getId());
         }
         $this->tagManager->deleteTags($this->tag->getId());
     } catch (TagNotFoundException $e) {
         // can happen if concurrent deletion occurred
         throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e);
     }
 }