Esempio n. 1
0
 /**
  * @covers \Netgen\TagsBundle\Core\Repository\TagsService::deleteTag
  * @depends testLoadTag
  * @depends testLoadTagSynonyms
  * @depends testLoadTagChildren
  */
 public function testDeleteTag()
 {
     $tag = $this->tagsService->loadTag(16);
     $tagSynonyms = $this->tagsService->loadTagSynonyms($tag);
     $tagChildren = $this->tagsService->loadTagChildren($tag);
     $this->tagsService->deleteTag($tag);
     try {
         $this->tagsService->loadTag($tag->id);
         $this->fail('Tag not deleted');
     } catch (NotFoundException $e) {
         // Do nothing
     }
     foreach ($tagSynonyms as $synonym) {
         try {
             $this->tagsService->loadTag($synonym->id);
             $this->fail('Synonym not deleted');
         } catch (NotFoundException $e) {
             // Do nothing
         }
     }
     foreach ($tagChildren as $child) {
         try {
             $this->tagsService->loadTag($child->id);
             $this->fail('Child not deleted');
         } catch (NotFoundException $e) {
             // Do nothing
         }
     }
 }
Esempio n. 2
0
 /**
  * Loads children of a tag object.
  *
  * @param string $tagPath
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Netgen\TagsBundle\Core\REST\Server\Values\CachedValue
  */
 public function loadTagChildren($tagPath, Request $request)
 {
     $offset = $request->query->has('offset') ? (int) $request->query->get('offset') : 0;
     $limit = $request->query->has('limit') ? (int) $request->query->get('limit') : 25;
     $tagId = $this->extractTagIdFromPath($tagPath);
     $children = $this->tagsService->loadTagChildren($tagId !== '0' ? $this->tagsService->loadTag($tagId) : null, $offset >= 0 ? $offset : 0, $limit >= 0 ? $limit : 25);
     $restTags = array();
     foreach ($children as $tag) {
         $restTags[] = new Values\RestTag($tag, 0, 0);
     }
     return new Values\CachedValue(new Values\TagList($restTags, $request->getPathInfo()), array('tagId' => $tagId));
 }
Esempio n. 3
0
 /**
  * Loads 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, tags from the first level will be returned
  * @param int $offset The start offset for paging
  * @param int $limit The number of tags returned. If $limit = -1 all children starting at $offset are 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 \Netgen\TagsBundle\API\Repository\Values\Tags\Tag[]
  */
 public function loadTagChildren(Tag $tag = null, $offset = 0, $limit = -1, array $languages = null, $useAlwaysAvailable = true)
 {
     return $this->service->loadTagChildren($tag, $offset, $limit, $languages, $useAlwaysAvailable);
 }