function createFile($tagId, $data = null)
 {
     try {
         $this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId);
     } catch (TagNotFoundException $e) {
         throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
     }
 }
Ejemplo n.º 2
0
 public function testAssignNonExistingTagInArray()
 {
     $caught = false;
     try {
         $this->tagMapper->assignTags(1, 'testtype', [100, $this->tag3->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 assigned');
 }
 function createFile($tagId, $data = null)
 {
     try {
         $tags = $this->tagManager->getTagsByIds([$tagId]);
         $tag = current($tags);
         if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
             throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
         }
         if (!$this->tagManager->canUserAssignTag($tag, $this->user)) {
             throw new Forbidden('No permission to assign tag ' . $tagId);
         }
         $this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId);
     } catch (TagNotFoundException $e) {
         throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
     }
 }
 function createFile($tagId, $data = null)
 {
     try {
         if (!$this->isAdmin) {
             $tag = $this->tagManager->getTagsByIds($tagId);
             $tag = current($tag);
             if (!$tag->isUserVisible()) {
                 throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
             }
             if (!$tag->isUserAssignable()) {
                 throw new Forbidden('No permission to assign tag ' . $tag->getId());
             }
         }
         $this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId);
     } catch (TagNotFoundException $e) {
         throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
     }
 }