Exemplo n.º 1
0
 /**
  * Merges two tags.
  *
  * @param string $tagPath
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @throws \eZ\Publish\Core\REST\Server\Exceptions\BadRequestException if the Destination header cannot be parsed as a tag
  *
  * @return \eZ\Publish\Core\REST\Server\Values\ResourceCreated
  */
 public function mergeTags($tagPath, Request $request)
 {
     $tag = $this->tagsService->loadTag($this->extractTagIdFromPath($tagPath));
     $destinationHref = $request->headers->get('Destination');
     try {
         $parsedDestinationHref = $this->requestParser->parseHref($destinationHref, 'tagPath');
     } catch (Exceptions\InvalidArgumentException $e) {
         throw new BadRequestException("{$destinationHref} is not an acceptable destination");
     }
     $targetTag = $this->tagsService->loadTag($this->extractTagIdFromPath($parsedDestinationHref));
     $this->tagsService->mergeTags($tag, $targetTag);
     return new BaseValues\NoContent();
 }
Exemplo n.º 2
0
 /**
  * Merges the $tag into the $targetTag.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If either of specified tags is not found
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to merge tags
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If either one of the tags is a synonym
  *                                                                        If the target tag is a sub tag of the given tag
  *
  * @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
  * @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $targetTag
  */
 public function mergeTags(Tag $tag, Tag $targetTag)
 {
     $this->service->mergeTags($tag, $targetTag);
     $this->signalDispatcher->emit(new MergeTagsSignal(array('tagId' => $tag->id, 'targetTagId' => $targetTag->id)));
 }
Exemplo n.º 3
0
 /**
  * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
  *
  * @covers \Netgen\TagsBundle\Core\Repository\TagsService::mergeTags
  */
 public function testMergeTagsThrowsUnauthorizedException()
 {
     $this->repository->setCurrentUser($this->getStubbedUser(10));
     $this->tagsService->mergeTags(new Tag(array('id' => 16)), new Tag(array('id' => 40)));
 }