/**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\ObjectState\ObjectStateUpdateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $objectStateUpdateStruct = $this->objectStateService->newObjectStateUpdateStruct();
     if (array_key_exists('identifier', $data)) {
         $objectStateUpdateStruct->identifier = $data['identifier'];
     }
     if (array_key_exists('defaultLanguageCode', $data)) {
         $objectStateUpdateStruct->defaultLanguageCode = $data['defaultLanguageCode'];
     }
     if (array_key_exists('names', $data)) {
         if (!is_array($data['names'])) {
             throw new Exceptions\Parser("Missing or invalid 'names' element for ObjectStateUpdate.");
         }
         if (!array_key_exists('value', $data['names']) || !is_array($data['names']['value'])) {
             throw new Exceptions\Parser("Missing or invalid 'names' element for ObjectStateUpdate.");
         }
         $objectStateUpdateStruct->names = $this->parserTools->parseTranslatableList($data['names']);
     }
     if (array_key_exists('descriptions', $data) && is_array($data['descriptions'])) {
         $objectStateUpdateStruct->descriptions = $this->parserTools->parseTranslatableList($data['descriptions']);
     }
     return $objectStateUpdateStruct;
 }
예제 #2
0
 /**
  * Instantiates a new Object State Update Struct.
  *
  * @return \eZ\Publish\API\Repository\Values\ObjectState\ObjectStateUpdateStruct
  */
 public function newObjectStateUpdateStruct()
 {
     return $this->service->newObjectStateUpdateStruct();
 }