Example #1
1
 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\User\UserCreateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $contentType = null;
     if (array_key_exists('ContentType', $data) && is_array($data['ContentType'])) {
         if (!array_key_exists('_href', $data['ContentType'])) {
             throw new Exceptions\Parser("Missing '_href' attribute for ContentType element in UserCreate.");
         }
         $contentType = $this->contentTypeService->loadContentType($this->requestParser->parseHref($data['ContentType']['_href'], 'contentTypeId'));
     }
     if (!array_key_exists('mainLanguageCode', $data)) {
         throw new Exceptions\Parser("Missing 'mainLanguageCode' element for UserCreate.");
     }
     if (!array_key_exists('login', $data)) {
         throw new Exceptions\Parser("Missing 'login' element for UserCreate.");
     }
     if (!array_key_exists('email', $data)) {
         throw new Exceptions\Parser("Missing 'email' element for UserCreate.");
     }
     if (!array_key_exists('password', $data)) {
         throw new Exceptions\Parser("Missing 'password' element for UserCreate.");
     }
     $userCreateStruct = $this->userService->newUserCreateStruct($data['login'], $data['email'], $data['password'], $data['mainLanguageCode'], $contentType);
     if (array_key_exists('Section', $data) && is_array($data['Section'])) {
         if (!array_key_exists('_href', $data['Section'])) {
             throw new Exceptions\Parser("Missing '_href' attribute for Section element in UserCreate.");
         }
         $userCreateStruct->sectionId = $this->requestParser->parseHref($data['Section']['_href'], 'sectionId');
     }
     if (array_key_exists('remoteId', $data)) {
         $userCreateStruct->remoteId = $data['remoteId'];
     }
     if (array_key_exists('enabled', $data)) {
         $userCreateStruct->enabled = $this->parserTools->parseBooleanValue($data['enabled']);
     }
     if (!array_key_exists('fields', $data) || !is_array($data['fields']) || !is_array($data['fields']['field'])) {
         throw new Exceptions\Parser("Missing or invalid 'fields' element for UserCreate.");
     }
     foreach ($data['fields']['field'] as $fieldData) {
         if (!array_key_exists('fieldDefinitionIdentifier', $fieldData)) {
             throw new Exceptions\Parser("Missing 'fieldDefinitionIdentifier' element in field data for UserCreate.");
         }
         $fieldDefinition = $userCreateStruct->contentType->getFieldDefinition($fieldData['fieldDefinitionIdentifier']);
         if (!$fieldDefinition) {
             throw new Exceptions\Parser("'{$fieldData['fieldDefinitionIdentifier']}' is invalid field definition identifier for '{$userCreateStruct->contentType->identifier}' content type in UserCreate.");
         }
         if (!array_key_exists('fieldValue', $fieldData)) {
             throw new Exceptions\Parser("Missing 'fieldValue' element for '{$fieldData['fieldDefinitionIdentifier']}' identifier in UserCreate.");
         }
         $fieldValue = $this->fieldTypeParser->parseValue($fieldDefinition->fieldTypeIdentifier, $fieldData['fieldValue']);
         $languageCode = null;
         if (array_key_exists('languageCode', $fieldData)) {
             $languageCode = $fieldData['languageCode'];
         }
         $userCreateStruct->setField($fieldData['fieldDefinitionIdentifier'], $fieldValue, $languageCode);
     }
     return $userCreateStruct;
 }
Example #2
0
 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return array
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     if (!array_key_exists('_type', $data)) {
         throw new Exceptions\Parser("Missing '_type' value for URLAliasCreate.");
     }
     if ($data['_type'] == 'LOCATION') {
         if (!array_key_exists('location', $data)) {
             throw new Exceptions\Parser("Missing 'location' value for URLAliasCreate.");
         }
         if (!is_array($data['location']) || !array_key_exists('_href', $data['location'])) {
             throw new Exceptions\Parser("Missing 'location' > '_href' attribute for URLAliasCreate.");
         }
     } else {
         if (!array_key_exists('resource', $data)) {
             throw new Exceptions\Parser("Missing 'resource' value for URLAliasCreate.");
         }
     }
     if (!array_key_exists('path', $data)) {
         throw new Exceptions\Parser("Missing 'path' value for URLAliasCreate.");
     }
     if (!array_key_exists('languageCode', $data)) {
         throw new Exceptions\Parser("Missing 'languageCode' value for URLAliasCreate.");
     }
     if (array_key_exists('alwaysAvailable', $data)) {
         $data['alwaysAvailable'] = $this->parserTools->parseBooleanValue($data['alwaysAvailable']);
     } else {
         $data['alwaysAvailable'] = false;
     }
     if (array_key_exists('forward', $data)) {
         $data['forward'] = $this->parserTools->parseBooleanValue($data['forward']);
     } else {
         $data['forward'] = false;
     }
     return $data;
 }
 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\ObjectState\ObjectStateCreateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     if (!array_key_exists('identifier', $data)) {
         throw new Exceptions\Parser("Missing 'identifier' attribute for ObjectStateCreate.");
     }
     $objectStateCreateStruct = $this->objectStateService->newObjectStateCreateStruct($data['identifier']);
     if (!array_key_exists('priority', $data)) {
         throw new Exceptions\Parser("Missing 'priority' attribute for ObjectStateCreate.");
     }
     $objectStateCreateStruct->priority = (int) $data['priority'];
     if (!array_key_exists('defaultLanguageCode', $data)) {
         throw new Exceptions\Parser("Missing 'defaultLanguageCode' attribute for ObjectStateCreate.");
     }
     $objectStateCreateStruct->defaultLanguageCode = $data['defaultLanguageCode'];
     if (!array_key_exists('names', $data) || !is_array($data['names'])) {
         throw new Exceptions\Parser("Missing or invalid 'names' element for ObjectStateCreate.");
     }
     if (!array_key_exists('value', $data['names']) || !is_array($data['names']['value'])) {
         throw new Exceptions\Parser("Missing or invalid 'names' element for ObjectStateCreate.");
     }
     $objectStateCreateStruct->names = $this->parserTools->parseTranslatableList($data['names']);
     // @todo XSD says that descriptions field is mandatory. Does that make sense?
     if (array_key_exists('descriptions', $data) && is_array($data['descriptions'])) {
         $objectStateCreateStruct->descriptions = $this->parserTools->parseTranslatableList($data['descriptions']);
     }
     return $objectStateCreateStruct;
 }
 /**
  * Parse input structure
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     if (!array_key_exists('ParentLocation', $data) || !is_array($data['ParentLocation'])) {
         throw new Exceptions\Parser("Missing or invalid 'ParentLocation' element for LocationCreate.");
     }
     if (!array_key_exists('_href', $data['ParentLocation'])) {
         throw new Exceptions\Parser("Missing '_href' attribute for ParentLocation element in LocationCreate.");
     }
     $locationHrefParts = explode('/', $this->requestParser->parseHref($data['ParentLocation']['_href'], 'locationPath'));
     $locationCreateStruct = $this->locationService->newLocationCreateStruct(array_pop($locationHrefParts));
     if (array_key_exists('priority', $data)) {
         $locationCreateStruct->priority = (int) $data['priority'];
     }
     if (array_key_exists('hidden', $data)) {
         $locationCreateStruct->hidden = $this->parserTools->parseBooleanValue($data['hidden']);
     }
     if (array_key_exists('remoteId', $data)) {
         $locationCreateStruct->remoteId = $data['remoteId'];
     }
     if (!array_key_exists('sortField', $data)) {
         throw new Exceptions\Parser("Missing 'sortField' element for LocationCreate.");
     }
     $locationCreateStruct->sortField = $this->parserTools->parseDefaultSortField($data['sortField']);
     if (!array_key_exists('sortOrder', $data)) {
         throw new Exceptions\Parser("Missing 'sortOrder' element for LocationCreate.");
     }
     $locationCreateStruct->sortOrder = $this->parserTools->parseDefaultSortOrder($data['sortOrder']);
     return $locationCreateStruct;
 }
Example #5
0
 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \Netgen\TagsBundle\API\Repository\Values\Tags\TagCreateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     if (!array_key_exists('ParentTag', $data) || !is_array($data['ParentTag'])) {
         throw new Exceptions\Parser("Missing or invalid 'ParentTag' element for TagCreate.");
     }
     if (!array_key_exists('_href', $data['ParentTag'])) {
         throw new Exceptions\Parser("Missing '_href' attribute for ParentTag element in TagCreate.");
     }
     if (!array_key_exists('mainLanguageCode', $data)) {
         throw new Exceptions\Parser("Missing 'mainLanguageCode' element for TagCreate.");
     }
     $tagHrefParts = explode('/', $this->requestParser->parseHref($data['ParentTag']['_href'], 'tagPath'));
     $tagCreateStruct = $this->tagsService->newTagCreateStruct(array_pop($tagHrefParts), $data['mainLanguageCode']);
     if (array_key_exists('remoteId', $data)) {
         $tagCreateStruct->remoteId = $data['remoteId'];
     }
     if (array_key_exists('alwaysAvailable', $data)) {
         $tagCreateStruct->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 TagCreate.");
         }
         $keywords = $this->parserTools->parseTranslatableList($data['names']);
         foreach ($keywords as $languageCode => $keyword) {
             $tagCreateStruct->setKeyword($keyword, $languageCode);
         }
     }
     return $tagCreateStruct;
 }
 /**
  * Parse input structure
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\Core\REST\Client\Values\FieldDefinitionList
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $fieldDefinitionReferences = array();
     foreach ($data['FieldDefinition'] as $fieldDefinitionData) {
         $fieldDefinitionReferences[] = $this->parserTools->parseObjectElement($fieldDefinitionData, $parsingDispatcher);
     }
     return new Values\FieldDefinitionList($this->contentTypeService, $fieldDefinitionReferences);
 }
 /**
  * Parse input structure
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\ContentType\FieldDefinitionUpdateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $fieldDefinitionUpdate = $this->contentTypeService->newFieldDefinitionUpdateStruct();
     if (array_key_exists('identifier', $data)) {
         $fieldDefinitionUpdate->identifier = $data['identifier'];
     }
     // @todo XSD says that descriptions is mandatory, but field definition can be updated without it
     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 FieldDefinitionUpdate.");
         }
         $fieldDefinitionUpdate->names = $this->parserTools->parseTranslatableList($data['names']);
     }
     // @todo XSD says that descriptions is mandatory, but field definition can be updated without it
     if (array_key_exists('descriptions', $data)) {
         if (!is_array($data['descriptions']) || !array_key_exists('value', $data['descriptions']) || !is_array($data['descriptions']['value'])) {
             throw new Exceptions\Parser("Invalid 'descriptions' element for FieldDefinitionUpdate.");
         }
         $fieldDefinitionUpdate->descriptions = $this->parserTools->parseTranslatableList($data['descriptions']);
     }
     // @todo XSD says that fieldGroup is mandatory, but field definition can be updated without it
     if (array_key_exists('fieldGroup', $data)) {
         $fieldDefinitionUpdate->fieldGroup = $data['fieldGroup'];
     }
     // @todo XSD says that position is mandatory, but field definition can be updated without it
     if (array_key_exists('position', $data)) {
         $fieldDefinitionUpdate->position = (int) $data['position'];
     }
     // @todo XSD says that isTranslatable is mandatory, but field definition can be updated without it
     if (array_key_exists('isTranslatable', $data)) {
         $fieldDefinitionUpdate->isTranslatable = $this->parserTools->parseBooleanValue($data['isTranslatable']);
     }
     // @todo XSD says that isRequired is mandatory, but field definition can be updated without it
     if (array_key_exists('isRequired', $data)) {
         $fieldDefinitionUpdate->isRequired = $this->parserTools->parseBooleanValue($data['isRequired']);
     }
     // @todo XSD says that isInfoCollector is mandatory, but field definition can be updated without it
     if (array_key_exists('isInfoCollector', $data)) {
         $fieldDefinitionUpdate->isInfoCollector = $this->parserTools->parseBooleanValue($data['isInfoCollector']);
     }
     // @todo XSD says that isSearchable is mandatory, but field definition can be updated without it
     if (array_key_exists('isSearchable', $data)) {
         $fieldDefinitionUpdate->isSearchable = $this->parserTools->parseBooleanValue($data['isSearchable']);
     }
     $fieldDefinition = $this->getFieldDefinition($data);
     // @todo XSD says that defaultValue is mandatory, but content type can be created without it
     if (array_key_exists('defaultValue', $data)) {
         $fieldDefinitionUpdate->defaultValue = $this->fieldTypeParser->parseValue($fieldDefinition->fieldTypeIdentifier, $data['defaultValue']);
     }
     if (array_key_exists('validatorConfiguration', $data)) {
         $fieldDefinitionUpdate->validatorConfiguration = $this->fieldTypeParser->parseValidatorConfiguration($fieldDefinition->fieldTypeIdentifier, $data['validatorConfiguration']);
     }
     if (array_key_exists('fieldSettings', $data)) {
         $fieldDefinitionUpdate->fieldSettings = $this->fieldTypeParser->parseFieldSettings($fieldDefinition->fieldTypeIdentifier, $data['fieldSettings']);
     }
     return $fieldDefinitionUpdate;
 }
 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\ContentType\ContentTypeUpdateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $contentTypeUpdateStruct = $this->contentTypeService->newContentTypeUpdateStruct();
     if (array_key_exists('identifier', $data)) {
         $contentTypeUpdateStruct->identifier = $data['identifier'];
     }
     if (array_key_exists('mainLanguageCode', $data)) {
         $contentTypeUpdateStruct->mainLanguageCode = $data['mainLanguageCode'];
     }
     if (array_key_exists('remoteId', $data)) {
         $contentTypeUpdateStruct->remoteId = $data['remoteId'];
     }
     if (array_key_exists('urlAliasSchema', $data)) {
         $contentTypeUpdateStruct->urlAliasSchema = $data['urlAliasSchema'];
     }
     if (array_key_exists('nameSchema', $data)) {
         $contentTypeUpdateStruct->nameSchema = $data['nameSchema'];
     }
     if (array_key_exists('isContainer', $data)) {
         $contentTypeUpdateStruct->isContainer = $this->parserTools->parseBooleanValue($data['isContainer']);
     }
     if (array_key_exists('defaultSortField', $data)) {
         $contentTypeUpdateStruct->defaultSortField = $this->parserTools->parseDefaultSortField($data['defaultSortField']);
     }
     if (array_key_exists('defaultSortOrder', $data)) {
         $contentTypeUpdateStruct->defaultSortOrder = $this->parserTools->parseDefaultSortOrder($data['defaultSortOrder']);
     }
     if (array_key_exists('defaultAlwaysAvailable', $data)) {
         $contentTypeUpdateStruct->defaultAlwaysAvailable = $this->parserTools->parseBooleanValue($data['defaultAlwaysAvailable']);
     }
     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 ContentTypeUpdate.");
         }
         $contentTypeUpdateStruct->names = $this->parserTools->parseTranslatableList($data['names']);
     }
     if (array_key_exists('descriptions', $data)) {
         if (!is_array($data['descriptions']) || !array_key_exists('value', $data['descriptions']) || !is_array($data['descriptions']['value'])) {
             throw new Exceptions\Parser("Invalid 'descriptions' element for ContentTypeUpdate.");
         }
         $contentTypeUpdateStruct->descriptions = $this->parserTools->parseTranslatableList($data['descriptions']);
     }
     if (array_key_exists('modificationDate', $data)) {
         $contentTypeUpdateStruct->modificationDate = new DateTime($data['modificationDate']);
     }
     if (array_key_exists('User', $data)) {
         if (!array_key_exists('_href', $data['User'])) {
             throw new Exceptions\Parser("Missing '_href' attribute for User element in ContentTypeUpdate.");
         }
         $contentTypeUpdateStruct->modifierId = $this->requestParser->parseHref($data['User']['_href'], 'userId');
     }
     return $contentTypeUpdateStruct;
 }
 /**
  * Parse input structure
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return array
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     if (!array_key_exists('sourceUrl', $data)) {
         throw new Exceptions\Parser("Missing 'sourceUrl' value for URLWildcardCreate.");
     }
     if (!array_key_exists('destinationUrl', $data)) {
         throw new Exceptions\Parser("Missing 'destinationUrl' value for URLWildcardCreate.");
     }
     if (!array_key_exists('forward', $data)) {
         throw new Exceptions\Parser("Missing 'forward' value for URLWildcardCreate.");
     }
     $data['forward'] = $this->parserTools->parseBooleanValue($data['forward']);
     return $data;
 }
Example #10
0
 /**
  * Parse input structure
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo
  * @todo Error handling
  * @todo What about missing properties? Set them here, using the service to
  *       load? Or better set them in the service, since loading is really
  *       unsuitable here?
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $contentTypeId = $this->parserTools->parseObjectElement($data['ContentType'], $parsingDispatcher);
     $ownerId = $this->parserTools->parseObjectElement($data['Owner'], $parsingDispatcher);
     $mainLocationId = $this->parserTools->parseObjectElement($data['MainLocation'], $parsingDispatcher);
     $sectionId = $this->parserTools->parseObjectElement($data['Section'], $parsingDispatcher);
     $locationListReference = $this->parserTools->parseObjectElement($data['Locations'], $parsingDispatcher);
     $versionListReference = $this->parserTools->parseObjectElement($data['Versions'], $parsingDispatcher);
     $currentVersionReference = $this->parserTools->parseObjectElement($data['CurrentVersion'], $parsingDispatcher);
     if (isset($data['CurrentVersion']['Version'])) {
         $this->parserTools->parseObjectElement($data['CurrentVersion']['Version'], $parsingDispatcher);
     }
     return new Values\RestContentInfo(array('id' => $data['_href'], 'name' => $data['Name'], 'contentTypeId' => $contentTypeId, 'ownerId' => $ownerId, 'modificationDate' => new \DateTime($data['lastModificationDate']), 'publishedDate' => $publishedDate = !empty($data['publishedDate']) ? new \DateTime($data['publishedDate']) : null, 'published' => $publishedDate !== null, 'alwaysAvailable' => strtolower($data['alwaysAvailable']) === 'true', 'remoteId' => $data['_remoteId'], 'mainLanguageCode' => $data['mainLanguageCode'], 'mainLocationId' => $mainLocationId, 'sectionId' => $sectionId, 'versionListReference' => $versionListReference, 'locationListReference' => $locationListReference, 'currentVersionReference' => $currentVersionReference));
 }
Example #11
0
 /**
  * Parse input structure
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $policyUpdate = $this->roleService->newPolicyUpdateStruct();
     // @todo XSD says that limitations field is mandatory, but
     // it needs to be possible to remove limitations from policy
     if (array_key_exists('limitations', $data)) {
         if (!is_array($data['limitations'])) {
             throw new Exceptions\Parser("Invalid format for 'limitations' in PolicyUpdate.");
         }
         if (!isset($data['limitations']['limitation']) || !is_array($data['limitations']['limitation'])) {
             throw new Exceptions\Parser("Invalid format for 'limitations' in PolicyUpdate.");
         }
         foreach ($data['limitations']['limitation'] as $limitationData) {
             $policyUpdate->addLimitation($this->parserTools->parseLimitation($limitationData));
         }
     }
     return $policyUpdate;
 }
 /**
  * Parse input structure
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\Core\REST\Server\Values\RoleAssignment
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     if (!array_key_exists('Role', $data)) {
         throw new Exceptions\Parser("Missing 'Role' element for RoleAssignInput.");
     }
     if (!is_array($data['Role']) || !array_key_exists('_href', $data['Role'])) {
         throw new Exceptions\Parser("Invalid 'Role' element for RoleAssignInput.");
     }
     try {
         $roleId = $this->requestParser->parseHref($data['Role']['_href'], 'roleId');
     } catch (Exceptions\InvalidArgumentException $e) {
         throw new Exceptions\Parser('Invalid format for <Role> reference in <RoleAssignInput>.');
     }
     // @todo XSD says that limitation is mandatory, but roles can be assigned without limitations
     $limitation = null;
     if (array_key_exists('limitation', $data) && is_array($data['limitation'])) {
         $limitation = $this->parserTools->parseLimitation($data['limitation']);
     }
     return new RoleAssignment($roleId, $limitation);
 }
 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroupCreateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     if (!array_key_exists('identifier', $data)) {
         throw new Exceptions\Parser("Missing 'identifier' attribute for ObjectStateGroupCreate.");
     }
     $objectStateGroupCreateStruct = $this->objectStateService->newObjectStateGroupCreateStruct($data['identifier']);
     if (!array_key_exists('defaultLanguageCode', $data)) {
         throw new Exceptions\Parser("Missing 'defaultLanguageCode' attribute for ObjectStateGroupCreate.");
     }
     $objectStateGroupCreateStruct->defaultLanguageCode = $data['defaultLanguageCode'];
     if (!array_key_exists('names', $data) || !is_array($data['names'])) {
         throw new Exceptions\Parser("Missing or invalid 'names' element for ObjectStateGroupCreate.");
     }
     if (!array_key_exists('value', $data['names']) || !is_array($data['names']['value'])) {
         throw new Exceptions\Parser("Missing or invalid 'names' element for ObjectStateGroupCreate.");
     }
     $objectStateGroupCreateStruct->names = $this->parserTools->parseTranslatableList($data['names']);
     if (array_key_exists('descriptions', $data) && is_array($data['descriptions'])) {
         $objectStateGroupCreateStruct->descriptions = $this->parserTools->parseTranslatableList($data['descriptions']);
     }
     return $objectStateGroupCreateStruct;
 }
Example #14
0
 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \Netgen\TagsBundle\API\Repository\Values\Tags\SynonymCreateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     if (!array_key_exists('mainLanguageCode', $data)) {
         throw new Exceptions\Parser("Missing 'mainLanguageCode' element for SynonymCreate.");
     }
     $synonymCreateStruct = $this->tagsService->newSynonymCreateStruct(null, $data['mainLanguageCode']);
     if (array_key_exists('remoteId', $data)) {
         $synonymCreateStruct->remoteId = $data['remoteId'];
     }
     if (array_key_exists('alwaysAvailable', $data)) {
         $synonymCreateStruct->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 SynonymCreate.");
         }
         $keywords = $this->parserTools->parseTranslatableList($data['names']);
         foreach ($keywords as $languageCode => $keyword) {
             $synonymCreateStruct->setKeyword($keyword, $languageCode);
         }
     }
     return $synonymCreateStruct;
 }
 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\Core\REST\Server\Values\RestLocationUpdateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $locationUpdateStruct = $this->locationService->newLocationUpdateStruct();
     if (array_key_exists('priority', $data)) {
         $locationUpdateStruct->priority = (int) $data['priority'];
     }
     if (array_key_exists('remoteId', $data)) {
         $locationUpdateStruct->remoteId = $data['remoteId'];
     }
     $hidden = null;
     if (array_key_exists('hidden', $data)) {
         $hidden = $this->parserTools->parseBooleanValue($data['hidden']);
     }
     if (!array_key_exists('sortField', $data)) {
         throw new Exceptions\Parser("Missing 'sortField' element for LocationUpdate.");
     }
     $locationUpdateStruct->sortField = $this->parserTools->parseDefaultSortField($data['sortField']);
     if (!array_key_exists('sortOrder', $data)) {
         throw new Exceptions\Parser("Missing 'sortOrder' element for LocationUpdate.");
     }
     $locationUpdateStruct->sortOrder = $this->parserTools->parseDefaultSortOrder($data['sortOrder']);
     return new RestLocationUpdateStruct($locationUpdateStruct, $hidden);
 }
 /**
  * Parse input structure
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\User\PolicyCreateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     if (!array_key_exists('module', $data)) {
         throw new Exceptions\Parser("Missing 'module' attribute for PolicyCreate.");
     }
     if (!array_key_exists('function', $data)) {
         throw new Exceptions\Parser("Missing 'function' attribute for PolicyCreate.");
     }
     $policyCreate = $this->roleService->newPolicyCreateStruct($data['module'], $data['function']);
     // @todo XSD says that limitations is mandatory,
     // but polices can be created without limitations
     if (array_key_exists('limitations', $data)) {
         if (!is_array($data['limitations'])) {
             throw new Exceptions\Parser("Invalid format for 'limitations' in PolicyCreate.");
         }
         if (!isset($data['limitations']['limitation']) || !is_array($data['limitations']['limitation'])) {
             throw new Exceptions\Parser("Invalid format for 'limitations' in PolicyCreate.");
         }
         foreach ($data['limitations']['limitation'] as $limitationData) {
             $policyCreate->addLimitation($this->parserTools->parseLimitation($limitationData));
         }
     }
     return $policyCreate;
 }
 /**
  * Parse input structure
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @todo Error handling
  *
  * @return \eZ\Publish\API\Repository\Values\ObjectState\ObjectState
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $names = $this->parserTools->parseTranslatableList($data['names']);
     $descriptions = isset($data['descriptions']) ? $this->parserTools->parseTranslatableList($data['descriptions']) : array();
     return new CoreObjectState(array('id' => $data['_href'], 'identifier' => $data['identifier'], 'priority' => (int) $data['priority'], 'defaultLanguageCode' => $data['defaultLanguageCode'], 'languageCodes' => explode(',', $data['languageCodes']), 'names' => $names, 'descriptions' => $descriptions));
 }
Example #18
0
 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @todo Error handling
  *
  * @return \eZ\Publish\API\Repository\Values\ContentType\FieldDefinition
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     return new Values\ContentType\FieldDefinition(array('id' => $data['_href'], 'identifier' => $data['identifier'], 'fieldTypeIdentifier' => $data['fieldType'], 'fieldGroup' => $data['fieldGroup'], 'position' => (int) $data['position'], 'isTranslatable' => $this->parserTools->parseBooleanValue($data['isTranslatable']), 'isRequired' => $this->parserTools->parseBooleanValue($data['isRequired']), 'isInfoCollector' => $this->parserTools->parseBooleanValue($data['isInfoCollector']), 'isSearchable' => $this->parserTools->parseBooleanValue($data['isSearchable']), 'names' => isset($data['names']) ? $this->parserTools->parseTranslatableList($data['names']) : null, 'descriptions' => isset($data['descriptions']) ? $this->parserTools->parseTranslatableList($data['descriptions']) : null, 'defaultValue' => $this->fieldTypeParser->parseValue($data['fieldType'], $data['defaultValue']), 'fieldSettings' => $this->fieldTypeParser->parseFieldSettings($data['fieldType'], $data['fieldSettings']), 'validators' => $this->fieldTypeParser->parseValidatorConfiguration($data['fieldType'], $data['validatorConfiguration'])));
 }
 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @todo Error handling
  *
  * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $contentInfoId = $this->requestParser->parseHref($data['Content']['_href'], 'contentId');
     return new Values\Content\VersionInfo($this->contentService, array('id' => $data['id'], 'versionNo' => $data['versionNo'], 'status' => $this->convertVersionStatus($data['status']), 'modificationDate' => new \DateTime($data['modificationDate']), 'creatorId' => $data['Creator']['_href'], 'creationDate' => new \DateTime($data['creationDate']), 'initialLanguageCode' => $data['initialLanguageCode'], 'languageCodes' => explode(',', $data['languageCodes']), 'names' => $this->parserTools->parseTranslatableList($data['names']), 'contentInfoId' => $contentInfoId));
 }
 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\ContentType\ContentTypeCreateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     if (!array_key_exists('identifier', $data)) {
         throw new Exceptions\Parser("Missing 'identifier' element for ContentTypeCreate.");
     }
     $contentTypeCreateStruct = $this->contentTypeService->newContentTypeCreateStruct($data['identifier']);
     if (!array_key_exists('mainLanguageCode', $data)) {
         throw new Exceptions\Parser("Missing 'mainLanguageCode' element for ContentTypeCreate.");
     }
     $contentTypeCreateStruct->mainLanguageCode = $data['mainLanguageCode'];
     if (array_key_exists('remoteId', $data)) {
         $contentTypeCreateStruct->remoteId = $data['remoteId'];
     }
     if (array_key_exists('urlAliasSchema', $data)) {
         $contentTypeCreateStruct->urlAliasSchema = $data['urlAliasSchema'];
     }
     // @todo XSD says that nameSchema is mandatory, but it is not in create struct
     if (array_key_exists('nameSchema', $data)) {
         $contentTypeCreateStruct->nameSchema = $data['nameSchema'];
     }
     // @todo XSD says that isContainer is mandatory, but it is not in create struct
     if (array_key_exists('isContainer', $data)) {
         $contentTypeCreateStruct->isContainer = $this->parserTools->parseBooleanValue($data['isContainer']);
     }
     // @todo XSD says that defaultSortField is mandatory, but it is not in create struct
     if (array_key_exists('defaultSortField', $data)) {
         $contentTypeCreateStruct->defaultSortField = $this->parserTools->parseDefaultSortField($data['defaultSortField']);
     }
     // @todo XSD says that defaultSortOrder is mandatory, but it is not in create struct
     if (array_key_exists('defaultSortOrder', $data)) {
         $contentTypeCreateStruct->defaultSortOrder = $this->parserTools->parseDefaultSortOrder($data['defaultSortOrder']);
     }
     // @todo XSD says that defaultAlwaysAvailable is mandatory, but it is not in create struct
     if (array_key_exists('defaultAlwaysAvailable', $data)) {
         $contentTypeCreateStruct->defaultAlwaysAvailable = $this->parserTools->parseBooleanValue($data['defaultAlwaysAvailable']);
     }
     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 ContentTypeCreate.");
         }
         $contentTypeCreateStruct->names = $this->parserTools->parseTranslatableList($data['names']);
     }
     // @todo XSD says that descriptions is mandatory, but content type can be created without descriptions
     if (array_key_exists('descriptions', $data)) {
         if (!is_array($data['descriptions']) || !array_key_exists('value', $data['descriptions']) || !is_array($data['descriptions']['value'])) {
             throw new Exceptions\Parser("Invalid 'descriptions' element for ContentTypeCreate.");
         }
         $contentTypeCreateStruct->descriptions = $this->parserTools->parseTranslatableList($data['descriptions']);
     }
     // @todo 1: XSD says that modificationDate is mandatory, but it is not in create struct
     // @todo 2: mismatch between XSD naming and create struct naming
     if (array_key_exists('modificationDate', $data)) {
         $contentTypeCreateStruct->creationDate = new DateTime($data['modificationDate']);
     }
     if (array_key_exists('User', $data)) {
         if (!array_key_exists('_href', $data['User'])) {
             throw new Exceptions\Parser("Missing '_href' attribute for User element in ContentTypeCreate.");
         }
         $contentTypeCreateStruct->creatorId = $this->requestParser->parseHref($data['User']['_href'], 'userId');
     }
     if (!array_key_exists('FieldDefinitions', $data)) {
         throw new Exceptions\Parser("Missing 'FieldDefinitions' element for ContentTypeCreate.");
     }
     if (!is_array($data['FieldDefinitions']) || !array_key_exists('FieldDefinition', $data['FieldDefinitions']) || !is_array($data['FieldDefinitions']['FieldDefinition'])) {
         throw new Exceptions\Parser("Invalid 'FieldDefinitions' element for ContentTypeCreate.");
     }
     // With no field definitions given and when ContentType is immediately published we must return HTTP 400 BadRequest,
     // instead of relying on service to throw InvalidArgumentException
     if (isset($data['__publish']) && $data['__publish'] === true && empty($data['FieldDefinitions']['FieldDefinition'])) {
         throw new Exceptions\Parser('ContentTypeCreate should provide at least one field definition.');
     }
     foreach ($data['FieldDefinitions']['FieldDefinition'] as $fieldDefinitionData) {
         if (!is_array($fieldDefinitionData)) {
             throw new Exceptions\Parser("Invalid 'FieldDefinition' element for ContentTypeCreate.");
         }
         $contentTypeCreateStruct->addFieldDefinition($this->fieldDefinitionCreateParser->parse($fieldDefinitionData, $parsingDispatcher));
     }
     return $contentTypeCreateStruct;
 }
 /**
  * Parse input structure
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType
  * @todo Error handling
  * @todo What about missing properties? Set them here, using the service to
  *       load? Or better set them in the service, since loading is really
  *       unsuitable here?
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $creatorId = $this->parserTools->parseObjectElement($data['Creator'], $parsingDispatcher);
     $modifierId = $this->parserTools->parseObjectElement($data['Modifier'], $parsingDispatcher);
     $fieldDefinitionListReference = $this->parserTools->parseObjectElement($data['FieldDefinitions'], $parsingDispatcher);
     $contentType = new Values\ContentType\ContentType($this->contentTypeService, array('id' => $data['_href'], 'status' => $this->parserTools->parseStatus($data['status']), 'identifier' => $data['identifier'], 'names' => isset($data['names']) ? $this->parserTools->parseTranslatableList($data['names']) : null, 'descriptions' => isset($data['descriptions']) ? $this->parserTools->parseTranslatableList($data['descriptions']) : null, 'creationDate' => new \DateTime($data['creationDate']), 'modificationDate' => new \DateTime($data['modificationDate']), 'creatorId' => $creatorId, 'modifierId' => $modifierId, 'remoteId' => $data['remoteId'], 'urlAliasSchema' => $data['urlAliasSchema'], 'nameSchema' => $data['nameSchema'], 'isContainer' => $this->parserTools->parseBooleanValue($data['isContainer']), 'mainLanguageCode' => $data['mainLanguageCode'], 'defaultAlwaysAvailable' => $this->parserTools->parseBooleanValue($data['defaultAlwaysAvailable']), 'defaultSortOrder' => $this->parserTools->parseDefaultSortOrder($data['defaultSortOrder']), 'defaultSortField' => $this->parserTools->parseDefaultSortField($data['defaultSortField']), 'fieldDefinitionListReference' => $fieldDefinitionListReference));
     if ($contentType->status === Values\ContentType\ContentType::STATUS_DRAFT) {
         return new Values\ContentType\ContentTypeDraft($contentType);
     }
     return $contentType;
 }
 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @todo Error handling
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Section
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $creatorId = $this->parserTools->parseObjectElement($data['Creator'], $parsingDispatcher);
     $modifierId = $this->parserTools->parseObjectElement($data['Modifier'], $parsingDispatcher);
     return new Values\ContentType\ContentTypeGroup(array('id' => $data['_href'], 'identifier' => $data['identifier'], 'creationDate' => new \DateTime($data['created']), 'modificationDate' => new \DateTime($data['modified']), 'creatorId' => $creatorId, 'modifierId' => $modifierId));
 }
 /**
  * Parse input structure
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\Core\REST\Server\Values\RestUserUpdateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $parsedData = array();
     //@todo XSD has a login element, but it's not possible to update login
     if (array_key_exists('email', $data)) {
         $parsedData['email'] = $data['email'];
     }
     if (array_key_exists('password', $data)) {
         $parsedData['password'] = $data['password'];
     }
     if (array_key_exists('enabled', $data)) {
         $parsedData['enabled'] = $this->parserTools->parseBooleanValue($data['enabled']);
     }
     if (array_key_exists('mainLanguageCode', $data)) {
         $parsedData['mainLanguageCode'] = $data['mainLanguageCode'];
     }
     if (array_key_exists('Section', $data) && is_array($data['Section'])) {
         if (!array_key_exists('_href', $data['Section'])) {
             throw new Exceptions\Parser("Missing '_href' attribute for Section element in UserUpdate.");
         }
         $parsedData['sectionId'] = $this->requestParser->parseHref($data['Section']['_href'], 'sectionId');
     }
     if (array_key_exists('remoteId', $data)) {
         $parsedData['remoteId'] = $data['remoteId'];
     }
     if (array_key_exists('fields', $data)) {
         $userId = $this->requestParser->parseHref($data['__url'], 'userId');
         if (!is_array($data['fields']) || !array_key_exists('field', $data['fields']) || !is_array($data['fields']['field'])) {
             throw new Exceptions\Parser("Invalid 'fields' element for UserUpdate.");
         }
         $parsedData['fields'] = array();
         foreach ($data['fields']['field'] as $fieldData) {
             if (!array_key_exists('fieldDefinitionIdentifier', $fieldData)) {
                 throw new Exceptions\Parser("Missing 'fieldDefinitionIdentifier' element in field data for UserUpdate.");
             }
             if (!array_key_exists('fieldValue', $fieldData)) {
                 throw new Exceptions\Parser("Missing 'fieldValue' element for '{$fieldData['fieldDefinitionIdentifier']}' identifier in UserUpdate.");
             }
             $fieldValue = $this->fieldTypeParser->parseFieldValue($userId, $fieldData['fieldDefinitionIdentifier'], $fieldData['fieldValue']);
             $languageCode = null;
             if (array_key_exists('languageCode', $fieldData)) {
                 $languageCode = $fieldData['languageCode'];
             }
             $parsedData['fields'][$fieldData['fieldDefinitionIdentifier']] = array('fieldValue' => $fieldValue, 'languageCode' => $languageCode);
         }
     }
     $userUpdateStruct = $this->userService->newUserUpdateStruct();
     if (!empty($parsedData)) {
         if (array_key_exists('email', $parsedData)) {
             $userUpdateStruct->email = $parsedData['email'];
         }
         if (array_key_exists('password', $parsedData)) {
             $userUpdateStruct->password = $parsedData['password'];
         }
         if (array_key_exists('enabled', $parsedData)) {
             $userUpdateStruct->enabled = $parsedData['enabled'];
         }
         if (array_key_exists('mainLanguageCode', $parsedData) || array_key_exists('remoteId', $parsedData)) {
             $userUpdateStruct->contentMetadataUpdateStruct = $this->contentService->newContentMetadataUpdateStruct();
             if (array_key_exists('mainLanguageCode', $parsedData)) {
                 $userUpdateStruct->contentMetadataUpdateStruct->mainLanguageCode = $parsedData['mainLanguageCode'];
             }
             if (array_key_exists('remoteId', $parsedData)) {
                 $userUpdateStruct->contentMetadataUpdateStruct->remoteId = $parsedData['remoteId'];
             }
         }
         if (array_key_exists('fields', $parsedData)) {
             $userUpdateStruct->contentUpdateStruct = $this->contentService->newContentUpdateStruct();
             foreach ($parsedData['fields'] as $fieldDefinitionIdentifier => $fieldValue) {
                 $userUpdateStruct->contentUpdateStruct->setField($fieldDefinitionIdentifier, $fieldValue['fieldValue'], $fieldValue['languageCode']);
             }
         }
     }
     return new RestUserUpdateStruct($userUpdateStruct, array_key_exists('sectionId', $parsedData) ? $parsedData['sectionId'] : null);
 }
 /**
  * Parse input structure
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @todo Error handling
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Location
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $content = $parsingDispatcher->parse($data['Content'], 'Content');
     return new Values\Content\Location(array('contentInfo' => $content instanceof APIContent ? $content->getVersionInfo()->getContentInfo() : null, 'id' => $data['_href'], 'priority' => (int) $data['priority'], 'hidden' => $data['hidden'] === 'true' ? true : false, 'invisible' => $data['invisible'] === 'true' ? true : false, 'remoteId' => $data['remoteId'], 'parentLocationId' => $data['ParentLocation']['_href'], 'pathString' => $data['pathString'], 'depth' => (int) $data['depth'], 'sortField' => $this->parserTools->parseDefaultSortField($data['sortField']), 'sortOrder' => $this->parserTools->parseDefaultSortOrder($data['sortOrder'])));
 }
 /**
  * Parse input structure
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\Core\REST\Server\Values\RestContentCreateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     if (!array_key_exists('LocationCreate', $data) || !is_array($data['LocationCreate'])) {
         throw new Exceptions\Parser("Missing or invalid 'LocationCreate' element for ContentCreate.");
     }
     $locationCreateStruct = $this->locationCreateParser->parse($data['LocationCreate'], $parsingDispatcher);
     if (!array_key_exists('ContentType', $data) || !is_array($data['ContentType'])) {
         throw new Exceptions\Parser("Missing or invalid 'ContentType' element for ContentCreate.");
     }
     if (!array_key_exists('_href', $data['ContentType'])) {
         throw new Exceptions\Parser("Missing '_href' attribute for ContentType element in ContentCreate.");
     }
     if (!array_key_exists('mainLanguageCode', $data)) {
         throw new Exceptions\Parser("Missing 'mainLanguageCode' element for ContentCreate.");
     }
     $contentType = $this->contentTypeService->loadContentType($this->requestParser->parseHref($data['ContentType']['_href'], 'contentTypeId'));
     $contentCreateStruct = $this->contentService->newContentCreateStruct($contentType, $data['mainLanguageCode']);
     if (array_key_exists('Section', $data) && is_array($data['Section'])) {
         if (!array_key_exists('_href', $data['Section'])) {
             throw new Exceptions\Parser("Missing '_href' attribute for Section element in ContentCreate.");
         }
         $contentCreateStruct->sectionId = $this->requestParser->parseHref($data['Section']['_href'], 'sectionId');
     }
     if (array_key_exists('alwaysAvailable', $data)) {
         $contentCreateStruct->alwaysAvailable = $this->parserTools->parseBooleanValue($data['alwaysAvailable']);
     }
     if (array_key_exists('remoteId', $data)) {
         $contentCreateStruct->remoteId = $data['remoteId'];
     }
     if (array_key_exists('modificationDate', $data)) {
         $contentCreateStruct->modificationDate = new DateTime($data['modificationDate']);
     }
     if (array_key_exists('User', $data) && is_array($data['User'])) {
         if (!array_key_exists('_href', $data['User'])) {
             throw new Exceptions\Parser("Missing '_href' attribute for User element in ContentCreate.");
         }
         $contentCreateStruct->ownerId = $this->requestParser->parseHref($data['User']['_href'], 'userId');
     }
     if (!array_key_exists('fields', $data) || !is_array($data['fields']) || !is_array($data['fields']['field'])) {
         throw new Exceptions\Parser("Missing or invalid 'fields' element for ContentCreate.");
     }
     foreach ($data['fields']['field'] as $fieldData) {
         if (!array_key_exists('fieldDefinitionIdentifier', $fieldData)) {
             throw new Exceptions\Parser("Missing 'fieldDefinitionIdentifier' element in field data for ContentCreate.");
         }
         $fieldDefinition = $contentType->getFieldDefinition($fieldData['fieldDefinitionIdentifier']);
         if (!$fieldDefinition) {
             throw new Exceptions\Parser("'{$fieldData['fieldDefinitionIdentifier']}' is invalid field definition identifier for '{$contentType->identifier}' content type in ContentCreate.");
         }
         if (!array_key_exists('fieldValue', $fieldData)) {
             throw new Exceptions\Parser("Missing 'fieldValue' element for '{$fieldData['fieldDefinitionIdentifier']}' identifier in ContentCreate.");
         }
         $fieldValue = $this->fieldTypeParser->parseValue($fieldDefinition->fieldTypeIdentifier, $fieldData['fieldValue']);
         $languageCode = null;
         if (array_key_exists('languageCode', $fieldData)) {
             $languageCode = $fieldData['languageCode'];
         }
         $contentCreateStruct->setField($fieldData['fieldDefinitionIdentifier'], $fieldValue, $languageCode);
     }
     return new RestContentCreateStruct($contentCreateStruct, $locationCreateStruct);
 }