コード例 #1
0
ファイル: Tags.php プロジェクト: netgen/tagsbundle
 /**
  * Updates a tag.
  *
  * @param string $tagPath
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Netgen\TagsBundle\Core\REST\Server\Values\RestTag
  */
 public function updateTag($tagPath, Request $request)
 {
     $tagUpdateStruct = $this->inputDispatcher->parse(new Message(array('Content-Type' => $request->headers->get('Content-Type')), $request->getContent()));
     $tag = $this->tagsService->loadTag($this->extractTagIdFromPath($tagPath));
     $updatedTag = $this->tagsService->updateTag($tag, $tagUpdateStruct);
     $childrenCount = 0;
     $synonymsCount = 0;
     if (empty($updatedTag->mainTagId)) {
         $childrenCount = $this->tagsService->getTagChildrenCount($updatedTag);
         $synonymsCount = $this->tagsService->getTagSynonymCount($updatedTag);
     }
     return new Values\RestTag($updatedTag, $childrenCount, $synonymsCount);
 }
コード例 #2
0
ファイル: TagsBase.php プロジェクト: umanit/TagsBundle
 /**
  * @covers \Netgen\TagsBundle\Core\Repository\TagsService::mergeTags
  * @depends testLoadTag
  * @depends testGetRelatedContentCount
  * @depends testGetTagChildrenCount
  */
 public function testMergeTags()
 {
     $tag = $this->tagsService->loadTag(16);
     $targetTag = $this->tagsService->loadTag(40);
     $this->tagsService->mergeTags($tag, $targetTag);
     try {
         $this->tagsService->loadTag($tag->id);
         $this->fail('Tag not deleted after merging');
     } catch (NotFoundException $e) {
         // Do nothing
     }
     $relatedObjectsCount = $this->tagsService->getRelatedContentCount($targetTag);
     $this->assertEquals(3, $relatedObjectsCount);
     $childrenCount = $this->tagsService->getTagChildrenCount($targetTag);
     $this->assertEquals(6, $childrenCount);
 }
コード例 #3
0
 /**
  * Returns the number of children of a tag object.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags
  *
  * @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag If null, tag count from the first level will be returned
  * @param array|null $languages A language filter for keywords. If not given all languages are returned.
  * @param bool $useAlwaysAvailable Add main language to $languages if true (default) and if tag is always available
  *
  * @return int
  */
 public function getTagChildrenCount(Tag $tag = null, array $languages = null, $useAlwaysAvailable = true)
 {
     return $this->service->getTagChildrenCount($tag, $languages, $useAlwaysAvailable);
 }