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


PHP FieldDefinitionInterface::isComputed方法代码示例

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


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

示例1: settingsForm

 /**
  * {@inheritdoc}
  */
 public static function settingsForm(FieldDefinitionInterface $field_definition)
 {
     $entity_manager = \Drupal::entityManager();
     $entity_type_id = $field_definition->getSetting('target_type');
     $selection_handler_settings = $field_definition->getSetting('handler_settings') ?: array();
     $entity_type = $entity_manager->getDefinition($entity_type_id);
     $bundles = $entity_manager->getBundleInfo($entity_type_id);
     // Merge-in default values.
     $selection_handler_settings += array('target_bundles' => array(), 'sort' => array('field' => '_none'), 'auto_create' => FALSE);
     if ($entity_type->hasKey('bundle')) {
         $bundle_options = array();
         foreach ($bundles as $bundle_name => $bundle_info) {
             $bundle_options[$bundle_name] = $bundle_info['label'];
         }
         $target_bundles_title = t('Bundles');
         // Default core entity types with sensible labels.
         if ($entity_type_id == 'node') {
             $target_bundles_title = t('Content types');
         } elseif ($entity_type_id == 'taxonomy_term') {
             $target_bundles_title = t('Vocabularies');
         }
         $form['target_bundles'] = array('#type' => 'checkboxes', '#title' => $target_bundles_title, '#options' => $bundle_options, '#default_value' => !empty($selection_handler_settings['target_bundles']) ? $selection_handler_settings['target_bundles'] : array(), '#required' => TRUE, '#size' => 6, '#multiple' => TRUE, '#element_validate' => array('_entity_reference_element_validate_filter'));
     } else {
         $form['target_bundles'] = array('#type' => 'value', '#value' => array());
     }
     if ($entity_type->isSubclassOf('\\Drupal\\Core\\Entity\\FieldableEntityInterface')) {
         $fields = array();
         foreach (array_keys($bundles) as $bundle) {
             $bundle_fields = array_filter($entity_manager->getFieldDefinitions($entity_type_id, $bundle), function ($field_definition) {
                 return !$field_definition->isComputed();
             });
             foreach ($bundle_fields as $field_name => $field_definition) {
                 /* @var \Drupal\Core\Field\FieldDefinitionInterface $field_definition */
                 $columns = $field_definition->getFieldStorageDefinition()->getColumns();
                 // If there is more than one column, display them all, otherwise just
                 // display the field label.
                 // @todo: Use property labels instead of the column name.
                 if (count($columns) > 1) {
                     foreach ($columns as $column_name => $column_info) {
                         $fields[$field_name . '.' . $column_name] = t('@label (@column)', array('@label' => $field_definition->getLabel(), '@column' => $column_name));
                     }
                 } else {
                     $fields[$field_name] = t('@label', array('@label' => $field_definition->getLabel()));
                 }
             }
         }
         $form['sort']['field'] = array('#type' => 'select', '#title' => t('Sort by'), '#options' => array('_none' => t('- None -')) + $fields, '#ajax' => TRUE, '#limit_validation_errors' => array(), '#default_value' => $selection_handler_settings['sort']['field']);
         $form['sort']['settings'] = array('#type' => 'container', '#attributes' => array('class' => array('entity_reference-settings')), '#process' => array('_entity_reference_form_process_merge_parent'));
         if ($selection_handler_settings['sort']['field'] != '_none') {
             // Merge-in default values.
             $selection_handler_settings['sort'] += array('direction' => 'ASC');
             $form['sort']['settings']['direction'] = array('#type' => 'select', '#title' => t('Sort direction'), '#required' => TRUE, '#options' => array('ASC' => t('Ascending'), 'DESC' => t('Descending')), '#default_value' => $selection_handler_settings['sort']['direction']);
         }
     }
     return $form;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:59,代码来源:SelectionBase.php


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