예제 #1
0
 /**
  * Loads synonyms of a tag object.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the tag is already a synonym
  *
  * @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
  * @param int $offset The start offset for paging
  * @param int $limit The number of synonyms returned. If $limit = -1 all synonyms 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 loadTagSynonyms(Tag $tag, $offset = 0, $limit = -1, array $languages = null, $useAlwaysAvailable = true)
 {
     if ($this->hasAccess('tags', 'read') !== true) {
         throw new UnauthorizedException('tags', 'read');
     }
     if ($tag->mainTagId > 0) {
         throw new InvalidArgumentException('tag', 'Tag is a synonym');
     }
     $spiTags = $this->tagsHandler->loadSynonyms($tag->id, $offset, $limit, $languages, $useAlwaysAvailable);
     $tags = array();
     foreach ($spiTags as $spiTag) {
         $tags[] = $this->buildTagDomainObject($spiTag);
     }
     return $tags;
 }