/** * Delete tag to object association */ public function delete() { try { $this->tagMapper->unassignTags($this->objectId, $this->objectType, $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 testUnassignNonExistingTagsInArray() { $caught = false; try { $this->tagMapper->unassignTags(1, 'testtype', [100, $this->tag1->getId()]); } catch (TagNotFoundException $e) { $caught = true; } $this->assertTrue($caught, 'Exception thrown'); $tagIdMapping = $this->tagMapper->getTagIdsForObjects([1], 'testtype'); $this->assertEquals([1 => [$this->tag1->getId(), $this->tag2->getId()]], $tagIdMapping, 'None of the tags got unassigned'); }
/** * Delete tag to object association */ 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 unassign tag ' . $this->tag->getId()); } $this->tagMapper->unassignTags($this->objectId, $this->objectType, $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); } }