Esempio n. 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);
 }
Esempio n. 2
0
 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \Netgen\TagsBundle\API\Repository\Values\Tags\TagUpdateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $tagUpdateStruct = $this->tagsService->newTagUpdateStruct();
     if (array_key_exists('mainLanguageCode', $data)) {
         $tagUpdateStruct->mainLanguageCode = $data['mainLanguageCode'];
     }
     if (array_key_exists('remoteId', $data)) {
         $tagUpdateStruct->remoteId = $data['remoteId'];
     }
     if (array_key_exists('alwaysAvailable', $data)) {
         $tagUpdateStruct->alwaysAvailable = $this->parserTools->parseBooleanValue($data['alwaysAvailable']);
     }
     if (array_key_exists('names', $data)) {
         if (!is_array($data['names']) || !array_key_exists('value', $data['names']) || !is_array($data['names']['value'])) {
             throw new Exceptions\Parser("Invalid 'names' element for TagUpdate.");
         }
         $keywords = $this->parserTools->parseTranslatableList($data['names']);
         foreach ($keywords as $languageCode => $keyword) {
             $tagUpdateStruct->setKeyword($keyword, $languageCode);
         }
     }
     return $tagUpdateStruct;
 }
Esempio n. 3
0
 /**
  * Instantiates a new tag update struct.
  *
  * @return \Netgen\TagsBundle\API\Repository\Values\Tags\TagUpdateStruct
  */
 public function newTagUpdateStruct()
 {
     return $this->service->newTagUpdateStruct();
 }