/**
  * Parses input structure to a SectionIdentifier Criterion object.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @throws \eZ\Publish\Core\REST\Common\Exceptions\Parser
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Query\Criterion\SectionId
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     if (!array_key_exists('SectionIdentifierCriterion', $data)) {
         throw new Exceptions\Parser('Invalid <SectionIdentifierCriterion> format');
     }
     $section = $this->sectionService->loadSectionByIdentifier($data['SectionIdentifierCriterion']);
     return new SectionIdCriterion($section->id);
 }
 /**
  * Checks if the passed value is valid.
  *
  * @param SectionUpdateData $value The value that should be validated
  * @param Constraint|UniqueFieldDefinitionIdentifier $constraint The constraint for the validation
  *
  * @api
  */
 public function validate($value, Constraint $constraint)
 {
     if (!$value instanceof SectionUpdateData) {
         return;
     }
     try {
         $section = $this->sectionService->loadSectionByIdentifier($value->identifier);
         if ($section->id == $value->getId()) {
             return;
         }
         $this->context->buildViolation($constraint->message)->atPath('identifier')->setParameter('%identifier%', $value->identifier)->addViolation();
     } catch (NotFoundException $e) {
         // Do nothing
     }
 }
 /**
  * Loads a Section from its identifier ($sectionIdentifier).
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if section could not be found
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user user is not allowed to read a section
  *
  * @param string $sectionIdentifier
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Section
  */
 public function loadSectionByIdentifier($sectionIdentifier)
 {
     return $this->service->loadSectionByIdentifier($sectionIdentifier);
 }
Beispiel #4
0
 /**
  * Loads section by identifier.
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Section
  */
 public function loadSectionByIdentifier(Request $request)
 {
     return $this->sectionService->loadSectionByIdentifier($request->query->get('identifier'));
 }