本文整理匯總了PHP中eZ\Publish\API\Repository\ContentTypeService::newContentTypeCreateStruct方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContentTypeService::newContentTypeCreateStruct方法的具體用法?PHP ContentTypeService::newContentTypeCreateStruct怎麽用?PHP ContentTypeService::newContentTypeCreateStruct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類eZ\Publish\API\Repository\ContentTypeService
的用法示例。
在下文中一共展示了ContentTypeService::newContentTypeCreateStruct方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getNewDraft
/**
* Create new content type draft
*
* @param array $data
* @return \eZ\Publish\API\Repository\Values\ContentType\ContentTypeDraft
*/
private function getNewDraft(array &$data)
{
$struct = $this->contentTypeService->newContentTypeCreateStruct($data['identifier']);
$this->fillValueObject($struct, $data);
$struct->mainLanguageCode = $this->getContentDataMainLanguage($data);
$groups = $this->getContentTypeGroups($data);
return $this->contentTypeService->createContentType($struct, $groups);
}
示例2: newContentTypeCreateStruct
/**
* Instantiates a new content type create class
*
* @param string $identifier
*
* @return \eZ\Publish\API\Repository\Values\ContentType\ContentTypeCreateStruct
*/
public function newContentTypeCreateStruct($identifier)
{
return $this->service->newContentTypeCreateStruct($identifier);
}
示例3: parse
/**
* 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;
}
示例4: newContentTypeCreateStruct
/**
* Creates a new content type create struct. If the identifier is not specified, a custom one is given.
*
* @return ContentTypeCreateStruct
*/
public function newContentTypeCreateStruct($identifier = null)
{
return $this->contentTypeService->newContentTypeCreateStruct($identifier ?: ($identifier = 'content_type_' . uniqid()));
}