/** * Loads the tag for a given ID (x)or remote ID. * * @param \Symfony\Component\HttpFoundation\Request $request * * @throws \eZ\Publish\Core\REST\Server\Exceptions\BadRequestException If the request does not have an ID or remote ID * * @return \eZ\Publish\Core\REST\Server\Values\TemporaryRedirect */ public function redirectTag(Request $request) { if (!$request->query->has('id') && !$request->query->has('remoteId')) { throw new BadRequestException("At least one of 'id' or 'remoteId' parameters is required."); } if ($request->query->has('id')) { $tag = $this->tagsService->loadTag($request->query->get('id')); } else { $tag = $this->tagsService->loadTagByRemoteId($request->query->get('remoteId')); } return new BaseValues\TemporaryRedirect($this->router->generate('ezpublish_rest_eztags_loadTag', array('tagPath' => trim($tag->pathString, '/')))); }
/** * Loads a tag object from its $remoteId. * * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to read tags * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified tag is not found * * @param string $remoteId * @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 loadTagByRemoteId($remoteId, array $languages = null, $useAlwaysAvailable = true) { return $this->service->loadTagByRemoteId($remoteId, $languages, $useAlwaysAvailable); }
/** * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException * * @covers \Netgen\TagsBundle\Core\Repository\TagsService::loadTagByRemoteId */ public function testLoadTagByRemoteIdThrowsUnauthorizedException() { $this->repository->setCurrentUser($this->getStubbedUser(10)); $this->tagsService->loadTagByRemoteId('182be0c5cdcd5072bb1864cdee4d3d6e'); }