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


PHP ContentTypeService::newFieldDefinitionUpdateStruct方法代码示例

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


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

示例1: parse

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

示例2: newFieldDefinitionUpdateStruct

 /**
  * Instantiates a field definition update class
  *
  * @return \eZ\Publish\API\Repository\Values\ContentType\FieldDefinitionUpdateStruct
  */
 public function newFieldDefinitionUpdateStruct()
 {
     return $this->service->newFieldDefinitionUpdateStruct();
 }
开发者ID:Jenkosama,项目名称:ezpublish-kernel,代码行数:9,代码来源:ContentTypeService.php

示例3: updateFieldDefinition

 /**
  * Helper function to update field definitions based to be added to a new/existing content type.
  *
  * @todo Add translation support if needed
  * @param ContentTypeService $contentTypeService
  * @param array $attribute
  * @return \eZ\Publish\API\Repository\Values\ContentType\FieldDefinitionUpdateStruct
  * @throws \Exception
  */
 private function updateFieldDefinition(ContentTypeService $contentTypeService, array $attribute)
 {
     if (!isset($attribute['identifier'])) {
         throw new \Exception("The 'identifier' of an attribute is missing in the content type update definition.");
     }
     $fieldDefinitionUpdateStruct = $contentTypeService->newFieldDefinitionUpdateStruct();
     foreach ($attribute as $key => $value) {
         switch ($key) {
             case 'new_identifier':
                 $fieldDefinitionUpdateStruct->identifier = $value;
                 break;
             case 'name':
                 $fieldDefinitionUpdateStruct->names = array($this->getLanguageCode() => $value);
                 break;
             case 'description':
                 $fieldDefinitionUpdateStruct->descriptions = array($this->getLanguageCode() => $value);
                 break;
             case 'required':
                 $fieldDefinitionUpdateStruct->isRequired = $value;
                 break;
             case 'searchable':
                 $fieldDefinitionUpdateStruct->isSearchable = $value;
                 break;
             case 'info-collector':
                 $fieldDefinitionUpdateStruct->isInfoCollector = $value;
                 break;
             case 'disable-translation':
                 $fieldDefinitionUpdateStruct->isTranslatable = !$value;
                 break;
             case 'category':
                 $fieldDefinitionUpdateStruct->fieldGroup = $value == 'default' ? 'content' : $value;
                 break;
             case 'default-value':
                 $fieldDefinitionUpdateStruct->defaultValue = $value;
                 break;
             case 'field-settings':
                 $fieldDefinitionUpdateStruct->fieldSettings = $this->getFieldSettings($value);
                 break;
             case 'position':
                 $fieldDefinitionUpdateStruct->position = $value;
                 break;
             case 'validator-configuration':
                 $fieldDefinitionUpdateStruct->validatorConfiguration = $value;
                 break;
         }
     }
     return $fieldDefinitionUpdateStruct;
 }
开发者ID:kaliop-uk,项目名称:ezmigrationbundle,代码行数:57,代码来源:ContentTypeManager.php


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