/** * Loads all tags with specified keyword. * * @param string $keyword * @param string $language * @param \Symfony\Component\HttpFoundation\Request $request * * @throws \eZ\Publish\Core\REST\Common\Exceptions\NotFoundException If no tag is found with specified path * * @return \Netgen\TagsBundle\Core\REST\Server\Values\CachedValue */ public function loadTagsByKeyword($keyword, $language, Request $request) { $offset = $request->query->has('offset') ? (int) $request->query->get('offset') : 0; $limit = $request->query->has('limit') ? (int) $request->query->get('limit') : 25; $tags = $this->tagsService->loadTagsByKeyword($keyword, $language, true, $offset >= 0 ? $offset : 0, $limit >= 0 ? $limit : 25); $restTags = array(); foreach ($tags as $tag) { $restTags[] = new Values\RestTag($tag, 0, 0); } return new Values\CachedValue(new Values\TagList($restTags, $request->getPathInfo()), array('tagKeyword' => $keyword . '|#' . $language)); }
/** * Loads tags by specified keyword. * * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags * * @param string $keyword The keyword to fetch tags for * @param string $language The language to check for * @param bool $useAlwaysAvailable Check for main language if true (default) and if tag is always available * @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 * * @return \Netgen\TagsBundle\API\Repository\Values\Tags\Tag[] */ public function loadTagsByKeyword($keyword, $language, $useAlwaysAvailable = true, $offset = 0, $limit = -1) { return $this->service->loadTagsByKeyword($keyword, $language, $useAlwaysAvailable, $offset, $limit); }
/** * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException * * @covers \Netgen\TagsBundle\Core\Repository\TagsService::loadTagsByKeyword */ public function testLoadTagsByKeywordThrowsUnauthorizedException() { $this->repository->setCurrentUser($this->getStubbedUser(10)); $this->tagsService->loadTagsByKeyword('eztags', 'eng-GB'); }