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


PHP Handler::updateFieldDefinition方法代码示例

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


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

示例1: updateFieldDefinition

 /**
  * Update a field definition
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the field id in the update struct is not found or does not belong to the content type
  *                                                                        If the given identifier is used in an existing field of the given content type
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to edit a content type
  *
  * @param \eZ\Publish\API\Repository\Values\ContentType\ContentTypeDraft $contentTypeDraft the content type draft
  * @param \eZ\Publish\API\Repository\Values\ContentType\FieldDefinition $fieldDefinition the field definition which should be updated
  * @param \eZ\Publish\API\Repository\Values\ContentType\FieldDefinitionUpdateStruct $fieldDefinitionUpdateStruct
  */
 public function updateFieldDefinition(APIContentTypeDraft $contentTypeDraft, APIFieldDefinition $fieldDefinition, FieldDefinitionUpdateStruct $fieldDefinitionUpdateStruct)
 {
     if ($this->repository->hasAccess('class', 'update') !== true) {
         throw new UnauthorizedException('ContentType', 'update');
     }
     $loadedContentTypeDraft = $this->loadContentTypeDraft($contentTypeDraft->id);
     $foundFieldId = false;
     foreach ($loadedContentTypeDraft->fieldDefinitions as $existingFieldDefinition) {
         if ($existingFieldDefinition->id == $fieldDefinition->id) {
             $foundFieldId = true;
         } else {
             if ($existingFieldDefinition->identifier == $fieldDefinitionUpdateStruct->identifier) {
                 throw new InvalidArgumentException("\$fieldDefinitionUpdateStruct", "Another FieldDefinition with identifier '{$fieldDefinitionUpdateStruct->identifier}' exists in the ContentType");
             }
         }
     }
     if (!$foundFieldId) {
         throw new InvalidArgumentException("\$fieldDefinition", "The given FieldDefinition does not belong to the ContentType");
     }
     $spiFieldDefinitionUpdateStruct = $this->buildSPIFieldDefinitionUpdate($fieldDefinitionUpdateStruct, $fieldDefinition);
     $this->repository->beginTransaction();
     try {
         $this->contentTypeHandler->updateFieldDefinition($contentTypeDraft->id, SPIContentType::STATUS_DRAFT, $spiFieldDefinitionUpdateStruct);
         $this->repository->commit();
     } catch (Exception $e) {
         $this->repository->rollback();
         throw $e;
     }
 }
开发者ID:dfritschy,项目名称:ezpublish-kernel,代码行数:40,代码来源:ContentTypeService.php

示例2: updateFieldDefinition

 /**
  * This method updates the given $fieldDefinition on a Type.
  *
  * This method creates a new status of the Type with the updated
  * $fieldDefinition. It does not update existing content objects depending
  * on the
  * field (default) values.
  *
  * @param mixed $contentTypeId
  * @param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDefinition
  * @return void
  */
 public function updateFieldDefinition($contentTypeId, $status, FieldDefinition $fieldDefinition)
 {
     $this->clearCache();
     return $this->innerHandler->updateFieldDefinition($contentTypeId, $status, $fieldDefinition);
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:17,代码来源:MemoryCachingHandler.php


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