本文整理汇总了PHP中eZ\Publish\API\Repository\ContentService::newContentMetadataUpdateStruct方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentService::newContentMetadataUpdateStruct方法的具体用法?PHP ContentService::newContentMetadataUpdateStruct怎么用?PHP ContentService::newContentMetadataUpdateStruct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\API\Repository\ContentService
的用法示例。
在下文中一共展示了ContentService::newContentMetadataUpdateStruct方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* Parse input structure.
*
* @param array $data
* @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
*
* @return \eZ\Publish\Core\REST\Server\Values\RestUserGroupUpdateStruct
*/
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
{
$parsedData = array();
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 UserGroupUpdate.");
}
$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)) {
$groupLocationParts = explode('/', $this->requestParser->parseHref($data['__url'], 'groupPath'));
$groupLocation = $this->locationService->loadLocation(array_pop($groupLocationParts));
if (!is_array($data['fields']) || !array_key_exists('field', $data['fields']) || !is_array($data['fields']['field'])) {
throw new Exceptions\Parser("Invalid 'fields' element for UserGroupUpdate.");
}
$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 UserGroupUpdate.");
}
if (!array_key_exists('fieldValue', $fieldData)) {
throw new Exceptions\Parser("Missing 'fieldValue' element for '{$fieldData['fieldDefinitionIdentifier']}' identifier in UserGroupUpdate.");
}
$fieldValue = $this->fieldTypeParser->parseFieldValue($groupLocation->contentId, $fieldData['fieldDefinitionIdentifier'], $fieldData['fieldValue']);
$languageCode = null;
if (array_key_exists('languageCode', $fieldData)) {
$languageCode = $fieldData['languageCode'];
}
$parsedData['fields'][$fieldData['fieldDefinitionIdentifier']] = array('fieldValue' => $fieldValue, 'languageCode' => $languageCode);
}
}
$userGroupUpdateStruct = $this->userService->newUserGroupUpdateStruct();
if (!empty($parsedData)) {
if (array_key_exists('mainLanguageCode', $parsedData) || array_key_exists('remoteId', $parsedData)) {
$userGroupUpdateStruct->contentMetadataUpdateStruct = $this->contentService->newContentMetadataUpdateStruct();
if (array_key_exists('mainLanguageCode', $parsedData)) {
$userGroupUpdateStruct->contentMetadataUpdateStruct->mainLanguageCode = $parsedData['mainLanguageCode'];
}
if (array_key_exists('remoteId', $parsedData)) {
$userGroupUpdateStruct->contentMetadataUpdateStruct->remoteId = $parsedData['remoteId'];
}
}
if (array_key_exists('fields', $parsedData)) {
$userGroupUpdateStruct->contentUpdateStruct = $this->contentService->newContentUpdateStruct();
foreach ($parsedData['fields'] as $fieldDefinitionIdentifier => $fieldValue) {
$userGroupUpdateStruct->contentUpdateStruct->setField($fieldDefinitionIdentifier, $fieldValue['fieldValue'], $fieldValue['languageCode']);
}
}
}
return new RestUserGroupUpdateStruct($userGroupUpdateStruct, array_key_exists('sectionId', $parsedData) ? $parsedData['sectionId'] : null);
}
示例2: newContentMetadataUpdateStruct
/**
* Instantiates a new content meta data update struct
*
* @return \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct
*/
public function newContentMetadataUpdateStruct()
{
return $this->service->newContentMetadataUpdateStruct();
}
示例3: parse
/**
* 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);
}