Ejemplo n.º 1
0
 /**
  * Makes sure LimitationValue->limitationValues is valid according to valueSchema().
  *
  * Make sure {@link acceptValue()} is checked first!
  *
  * @param \eZ\Publish\API\Repository\Values\User\Limitation $limitationValue
  *
  * @return \eZ\Publish\SPI\FieldType\ValidationError[]
  */
 public function validate(APILimitationValue $limitationValue)
 {
     $validationErrors = array();
     foreach ($limitationValue->limitationValues as $key => $id) {
         try {
             $this->tagsPersistence->loadTagInfo($id);
         } catch (NotFoundException $e) {
             $validationErrors[] = new ValidationError("limitationValues[%key%] => '%value%' does not exist in the backend", null, array('value' => $id, 'key' => $key));
         }
     }
     return $validationErrors;
 }
Ejemplo n.º 2
0
 /**
  * Deletes $tag and all its descendants and synonyms.
  *
  * If $tag is a synonym, only the synonym is deleted
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to delete this tag
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified tag is not found
  *
  * @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
  */
 public function deleteTag(Tag $tag)
 {
     if ($tag->mainTagId > 0) {
         if ($this->hasAccess('tags', 'deletesynonym') !== true) {
             throw new UnauthorizedException('tags', 'deletesynonym');
         }
     } else {
         if ($this->hasAccess('tags', 'delete') !== true) {
             throw new UnauthorizedException('tags', 'delete');
         }
     }
     $this->repository->beginTransaction();
     try {
         $this->tagsHandler->deleteTag($tag->id);
         $this->repository->commit();
     } catch (Exception $e) {
         $this->repository->rollback();
         throw $e;
     }
 }