当前位置: 首页>>代码示例>>PHP>>正文


PHP ContentService::newContentCreateStruct方法代码示例

本文整理汇总了PHP中eZ\Publish\API\Repository\ContentService::newContentCreateStruct方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentService::newContentCreateStruct方法的具体用法?PHP ContentService::newContentCreateStruct怎么用?PHP ContentService::newContentCreateStruct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZ\Publish\API\Repository\ContentService的用法示例。


在下文中一共展示了ContentService::newContentCreateStruct方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getContentCreateStruct

 /**
  * Creates and prepares content create structure.
  *
  * @param array $data
  * @return \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct
  */
 private function getContentCreateStruct($data)
 {
     $contentType = $this->contentTypeService->loadContentTypeByIdentifier($data['content_type']);
     $struct = $this->contentService->newContentCreateStruct($contentType, '');
     $this->fillValueObject($struct, $data, ['content_type']);
     return $struct;
 }
开发者ID:silversolutions,项目名称:content-loader-bundle,代码行数:13,代码来源:Content.php

示例2: iSetTheContentToUserContentCreateStruct

 /**
  * @Given /^I set the Content to a User RestContentCreateStruct$/
  */
 public function iSetTheContentToUserContentCreateStruct()
 {
     $contentCreateStruct = $this->contentService->newContentCreateStruct($this->contentTypeService->loadContentTypeByIdentifier('user'), 'eng-GB');
     $userFieldValue = new UserValue(['login' => 'user_content_' . time(), 'email' => 'user_content_' . time() . '@example.com', 'passwordHash' => 'not_a_hash']);
     $contentCreateStruct->setField('first_name', new TextLineValue('User Content'));
     $contentCreateStruct->setField('last_name', new TextLineValue('@' . microtime(true)));
     $contentCreateStruct->setField('user_account', $userFieldValue);
     $restStruct = new RestContentCreateStruct($contentCreateStruct, new LocationCreateStruct(['parentLocationId' => 12]));
     $this->restContext->requestObject = $restStruct;
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:13,代码来源:UserContentContext.php

示例3: createContentDraft

 /**
  * Creates a content draft.
  *
  * @param eZ\Publish\API\Repository\Values\Content\Location $parentLocationId
  * @param string $contentTypeIdentifier
  * @param string $languageCode
  * @param array $fields Fields, as primitives understood by setField
  *
  * @return eZ\Publish\API\Repository\Values\Content\Content an unpublished Content draft
  */
 public function createContentDraft($parentLocationId, $contentTypeIdentifier, $fields, $languageCode = null)
 {
     $languageCode = $languageCode ?: self::DEFAULT_LANGUAGE;
     $repository = $this->getRepository();
     $locationCreateStruct = $repository->getLocationService()->newLocationCreateStruct($parentLocationId);
     $contentTypeIdentifier = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier);
     $contentCreateStruct = $this->contentService->newContentCreateStruct($contentTypeIdentifier, $languageCode);
     foreach (array_keys($fields) as $key) {
         $contentCreateStruct->setField($key, $fields[$key]);
     }
     return $this->contentService->createContent($contentCreateStruct, array($locationCreateStruct));
 }
开发者ID:emodric,项目名称:ezpublish-kernel,代码行数:22,代码来源:BasicContentContext.php

示例4: newContentCreateStruct

 /**
  * Instantiates a new content create struct object
  *
  * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
  * @param string $mainLanguageCode
  *
  * @return \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct
  */
 public function newContentCreateStruct(ContentType $contentType, $mainLanguageCode)
 {
     return $this->service->newContentCreateStruct($contentType, $mainLanguageCode);
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:12,代码来源:ContentService.php

示例5: parse

 /**
  * 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);
 }
开发者ID:dfritschy,项目名称:ezpublish-kernel,代码行数:69,代码来源:ContentCreate.php


注:本文中的eZ\Publish\API\Repository\ContentService::newContentCreateStruct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。