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


PHP Handler::getContentCount方法代码示例

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


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

示例1: addFieldDefinition

 /**
  * Adds a new field definition to an existing content type.
  *
  * The content type must be in state DRAFT.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the identifier in already exists in the content type
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to edit a content type
  * @throws \eZ\Publish\API\Repository\Exceptions\ContentTypeFieldDefinitionValidationException
  *         if a field definition in the $contentTypeCreateStruct is not valid
  * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If field definition of the same non-repeatable type is being
  *                                                                 added to the ContentType that already contains one
  *                                                                 or field definition that can't be added to a ContentType that
  *                                                                 has Content instances is being added to such ContentType
  *
  * @param \eZ\Publish\API\Repository\Values\ContentType\ContentTypeDraft $contentTypeDraft
  * @param \eZ\Publish\API\Repository\Values\ContentType\FieldDefinitionCreateStruct $fieldDefinitionCreateStruct
  */
 public function addFieldDefinition(APIContentTypeDraft $contentTypeDraft, FieldDefinitionCreateStruct $fieldDefinitionCreateStruct)
 {
     if ($this->repository->hasAccess('class', 'update') !== true) {
         throw new UnauthorizedException('ContentType', 'update');
     }
     $this->validateInputFieldDefinitionCreateStruct($fieldDefinitionCreateStruct);
     $loadedContentTypeDraft = $this->loadContentTypeDraft($contentTypeDraft->id);
     if ($loadedContentTypeDraft->getFieldDefinition($fieldDefinitionCreateStruct->identifier) !== null) {
         throw new InvalidArgumentException("\$fieldDefinitionCreateStruct", "Another FieldDefinition with identifier '{$fieldDefinitionCreateStruct->identifier}' exists in the ContentType");
     }
     /** @var $fieldType \eZ\Publish\SPI\FieldType\FieldType */
     $fieldType = $this->repository->getFieldTypeService()->buildFieldType($fieldDefinitionCreateStruct->fieldTypeIdentifier);
     $fieldType->applyDefaultSettings($fieldDefinitionCreateStruct->fieldSettings);
     $fieldType->applyDefaultValidatorConfiguration($fieldDefinitionCreateStruct->validatorConfiguration);
     $validationErrors = $this->validateFieldDefinitionCreateStruct($fieldDefinitionCreateStruct, $fieldType);
     if (!empty($validationErrors)) {
         $validationErrors = array($fieldDefinitionCreateStruct->identifier => $validationErrors);
         throw new ContentTypeFieldDefinitionValidationException($validationErrors);
     }
     if ($fieldType->isSingular()) {
         foreach ($loadedContentTypeDraft->getFieldDefinitions() as $fieldDefinition) {
             if ($fieldDefinition->fieldTypeIdentifier === $fieldDefinitionCreateStruct->fieldTypeIdentifier) {
                 throw new BadStateException("\$contentTypeDraft", "ContentType already contains field definition of non-repeatable field type '{$fieldDefinition->fieldTypeIdentifier}'");
             }
         }
     }
     if ($fieldType->onlyEmptyInstance() && $this->contentTypeHandler->getContentCount($loadedContentTypeDraft->id)) {
         throw new BadStateException("\$contentTypeDraft", "Field definition of '{$fieldDefinitionCreateStruct->fieldTypeIdentifier}' field type cannot be added because ContentType has Content instances");
     }
     $spiFieldDefinitionCreateStruct = $this->buildSPIFieldDefinitionCreate($fieldDefinitionCreateStruct, $fieldType);
     $this->repository->beginTransaction();
     try {
         $this->contentTypeHandler->addFieldDefinition($contentTypeDraft->id, $contentTypeDraft->status, $spiFieldDefinitionCreateStruct);
         $this->repository->commit();
     } catch (Exception $e) {
         $this->repository->rollback();
         throw $e;
     }
 }
开发者ID:dfritschy,项目名称:ezpublish-kernel,代码行数:56,代码来源:ContentTypeService.php

示例2: getContentCount

 /**
  * Counts the number of Content instances of the ContentType identified by given $contentTypeId.
  *
  * @param mixed $contentTypeId
  *
  * @return int
  */
 public function getContentCount($contentTypeId)
 {
     return $this->innerHandler->getContentCount($contentTypeId);
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:11,代码来源:MemoryCachingHandler.php

示例3: isContentTypeUsed

 /**
  * Returns true if the given content type $contentType has content instances.
  *
  * @since 6.0.1
  *
  * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
  *
  * @return bool
  */
 public function isContentTypeUsed(APIContentType $contentType)
 {
     return $this->contentTypeHandler->getContentCount($contentType->id) > 0;
 }
开发者ID:emodric,项目名称:ezpublish-kernel,代码行数:13,代码来源:ContentTypeService.php


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