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


PHP FieldStorageDefinitionInterface::isReadOnly方法代码示例

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


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

示例1: isDestinationFieldCompatible

 /**
  * Check if a field on the entity type to update is a possible destination field.
  *
  * @todo Should this be on our FieldManager service?
  *
  * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $definition
  *  Field definition on entity type to update to check.
  * @param \Drupal\Core\Field\FieldDefinitionInterface $source_field
  *  Source field to check compatibility against. If none then check generally.
  *
  * @return bool
  */
 protected function isDestinationFieldCompatible(FieldStorageDefinitionInterface $definition, FieldDefinitionInterface $source_field = NULL)
 {
     // @todo Create field definition wrapper class to treat FieldDefinitionInterface and FieldStorageDefinitionInterface the same.
     if ($definition instanceof BaseFieldDefinition && $definition->isReadOnly()) {
         return FALSE;
     }
     // Don't allow updates on updates!
     if ($definition->getType() == 'entity_reference') {
         if ($definition->getSetting('target_type') == 'scheduled_update') {
             return FALSE;
         }
     }
     if ($source_field) {
         $matching_types = $this->getMatchingFieldTypes($source_field->getType());
         if (!in_array($definition->getType(), $matching_types)) {
             return FALSE;
         }
         // Check cardinality
         $destination_cardinality = $definition->getCardinality();
         $source_cardinality = $source_field->getFieldStorageDefinition()->getCardinality();
         // $destination_cardinality is unlimited. It doesn't matter what source is.
         if ($destination_cardinality != -1) {
             if ($source_cardinality == -1) {
                 return FALSE;
             }
             if ($source_cardinality > $destination_cardinality) {
                 return FALSE;
             }
         }
         switch ($definition->getType()) {
             case 'entity_reference':
                 // Entity reference field must match entity target types.
                 if ($definition->getSetting('target_type') != $source_field->getSetting('target_type')) {
                     return FALSE;
                 }
                 // @todo Check bundles
                 break;
                 // @todo Other type specific conditions?
         }
     }
     return TRUE;
 }
开发者ID:tedbow,项目名称:scheduled-updates-demo,代码行数:54,代码来源:FieldUtilsTrait.php


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