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


PHP FieldTypePluginManagerInterface::getPluginClass方法代码示例

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


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

示例1: mapToStorageRecord

 /**
  * {@inheritdoc}
  */
 protected function mapToStorageRecord(EntityInterface $entity)
 {
     $record = parent::mapToStorageRecord($entity);
     $class = $this->fieldTypeManager->getPluginClass($record['field_type']);
     $record['settings'] = $class::fieldSettingsToConfigData($record['settings']);
     return $record;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:10,代码来源:FieldConfigStorageBase.php

示例2: processStubRow

 /**
  * Populates as much of the stub row as possible.
  *
  * @param \Drupal\migrate\Row $row
  *   The row of data.
  */
 protected function processStubRow(Row $row)
 {
     $bundle_key = $this->getKey('bundle');
     if ($bundle_key && empty($row->getDestinationProperty($bundle_key))) {
         if (empty($this->bundles)) {
             throw new MigrateException('Stubbing failed, no bundles available for entity type: ' . $this->storage->getEntityTypeId());
         }
         $row->setDestinationProperty($bundle_key, reset($this->bundles));
     }
     // Populate any required fields not already populated.
     $fields = $this->entityManager->getFieldDefinitions($this->storage->getEntityTypeId(), $bundle_key);
     foreach ($fields as $field_name => $field_definition) {
         if ($field_definition->isRequired() && is_null($row->getDestinationProperty($field_name))) {
             // Use the configured default value for this specific field, if any.
             if ($default_value = $field_definition->getDefaultValueLiteral()) {
                 $values[] = $default_value;
             } else {
                 // Otherwise, ask the field type to generate a sample value.
                 $field_type = $field_definition->getType();
                 /** @var \Drupal\Core\Field\FieldItemInterface $field_type_class */
                 $field_type_class = $this->fieldTypeManager->getPluginClass($field_definition->getType());
                 $values = $field_type_class::generateSampleValue($field_definition);
                 if (is_null($values)) {
                     // Handle failure to generate a sample value.
                     throw new MigrateException('Stubbing failed, unable to generate value for field ' . $field_name);
                 }
             }
             $row->setDestinationProperty($field_name, $values);
         }
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:37,代码来源:EntityContentBase.php


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