예제 #1
0
 /**
  * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
  *
  * @covers \Netgen\TagsBundle\Core\Repository\TagsService::updateTag
  * @depends testNewTagUpdateStruct
  */
 public function testUpdateTagThrowsUnauthorizedExceptionForSynonym()
 {
     $this->repository->setCurrentUser($this->getStubbedUser(10));
     $updateStruct = $this->tagsService->newTagUpdateStruct();
     $updateStruct->setKeyword('New keyword');
     $updateStruct->remoteId = 'New remote ID';
     $this->tagsService->updateTag(new Tag(array('id' => 95)), $updateStruct);
 }
예제 #2
0
파일: Tags.php 프로젝트: netgen/tagsbundle
 /**
  * Updates a tag.
  *
  * @param string $tagPath
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Netgen\TagsBundle\Core\REST\Server\Values\RestTag
  */
 public function updateTag($tagPath, Request $request)
 {
     $tagUpdateStruct = $this->inputDispatcher->parse(new Message(array('Content-Type' => $request->headers->get('Content-Type')), $request->getContent()));
     $tag = $this->tagsService->loadTag($this->extractTagIdFromPath($tagPath));
     $updatedTag = $this->tagsService->updateTag($tag, $tagUpdateStruct);
     $childrenCount = 0;
     $synonymsCount = 0;
     if (empty($updatedTag->mainTagId)) {
         $childrenCount = $this->tagsService->getTagChildrenCount($updatedTag);
         $synonymsCount = $this->tagsService->getTagSynonymCount($updatedTag);
     }
     return new Values\RestTag($updatedTag, $childrenCount, $synonymsCount);
 }
예제 #3
0
 /**
  * Updates $tag.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified tag is not found
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to update this tag
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the remote ID already exists
  *
  * @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
  * @param \Netgen\TagsBundle\API\Repository\Values\Tags\TagUpdateStruct $tagUpdateStruct
  *
  * @return \Netgen\TagsBundle\API\Repository\Values\Tags\Tag The updated tag
  */
 public function updateTag(Tag $tag, TagUpdateStruct $tagUpdateStruct)
 {
     $returnValue = $this->service->updateTag($tag, $tagUpdateStruct);
     $this->signalDispatcher->emit(new UpdateTagSignal(array('tagId' => $returnValue->id, 'keywords' => $returnValue->keywords, 'remoteId' => $returnValue->remoteId, 'mainLanguageCode' => $returnValue->mainLanguageCode, 'alwaysAvailable' => $returnValue->alwaysAvailable)));
     return $returnValue;
 }