/** * Returns the number of 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 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 getTagSynonymCount(Tag $tag, 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'); } return $this->tagsHandler->getSynonymCount($tag->id, $languages, $useAlwaysAvailable); }