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


PHP FieldDefinitionInterface::getDescription方法代码示例

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


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

示例1: formMultipleElements

 /**
  * Special handling to create form elements for multiple values.
  *
  * Handles generic features for multiple fields:
  * - number of widgets
  * - AHAH-'add more' button
  * - table display and drag-n-drop value reordering
  */
 protected function formMultipleElements(FieldItemListInterface $items, array &$form, FormStateInterface $form_state)
 {
     $field_name = $this->fieldDefinition->getName();
     $cardinality = $this->fieldDefinition->getFieldStorageDefinition()->getCardinality();
     $parents = $form['#parents'];
     // Determine the number of widgets to display.
     switch ($cardinality) {
         case FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED:
             $field_state = static::getWidgetState($parents, $field_name, $form_state);
             $max = $field_state['items_count'];
             $is_multiple = TRUE;
             break;
         default:
             $max = $cardinality - 1;
             $is_multiple = $cardinality > 1;
             break;
     }
     $title = $this->fieldDefinition->getLabel();
     $description = FieldFilteredMarkup::create(\Drupal::token()->replace($this->fieldDefinition->getDescription()));
     $elements = array();
     for ($delta = 0; $delta <= $max; $delta++) {
         // Add a new empty item if it doesn't exist yet at this delta.
         if (!isset($items[$delta])) {
             $items->appendItem();
         }
         // For multiple fields, title and description are handled by the wrapping
         // table.
         if ($is_multiple) {
             $element = ['#title' => $this->t('@title (value @number)', ['@title' => $title, '@number' => $delta + 1]), '#title_display' => 'invisible', '#description' => ''];
         } else {
             $element = ['#title' => $title, '#title_display' => 'before', '#description' => $description];
         }
         $element = $this->formSingleElement($items, $delta, $element, $form, $form_state);
         if ($element) {
             // Input field for the delta (drag-n-drop reordering).
             if ($is_multiple) {
                 // We name the element '_weight' to avoid clashing with elements
                 // defined by widget.
                 $element['_weight'] = array('#type' => 'weight', '#title' => $this->t('Weight for row @number', array('@number' => $delta + 1)), '#title_display' => 'invisible', '#delta' => $max, '#default_value' => $items[$delta]->_weight ?: $delta, '#weight' => 100);
             }
             $elements[$delta] = $element;
         }
     }
     if ($elements) {
         $elements += array('#theme' => 'field_multiple_value_form', '#field_name' => $field_name, '#cardinality' => $cardinality, '#cardinality_multiple' => $this->fieldDefinition->getFieldStorageDefinition()->isMultiple(), '#required' => $this->fieldDefinition->isRequired(), '#title' => $title, '#description' => $description, '#max_delta' => $max);
         // Add 'add more' button, if not working with a programmed form.
         if ($cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED && !$form_state->isProgrammed()) {
             $id_prefix = implode('-', array_merge($parents, array($field_name)));
             $wrapper_id = Html::getUniqueId($id_prefix . '-add-more-wrapper');
             $elements['#prefix'] = '<div id="' . $wrapper_id . '">';
             $elements['#suffix'] = '</div>';
             $elements['add_more'] = array('#type' => 'submit', '#name' => strtr($id_prefix, '-', '_') . '_add_more', '#value' => t('Add another item'), '#attributes' => array('class' => array('field-add-more-submit')), '#limit_validation_errors' => array(array_merge($parents, array($field_name))), '#submit' => array(array(get_class($this), 'addMoreSubmit')), '#ajax' => array('callback' => array(get_class($this), 'addMoreAjax'), 'wrapper' => $wrapper_id, 'effect' => 'fade'));
         }
     }
     return $elements;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:64,代码来源:WidgetBase.php

示例2: getDescription

 /**
  * {@inheritdoc}
  */
 public function getDescription()
 {
     return $this->fieldDefinition->getDescription();
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:7,代码来源:FieldTargetDefinition.php

示例3: mapSingleFieldViewsData

 /**
  * Provides the views data for a given data type and schema field.
  *
  * @param string $table
  *   The table of the field to handle.
  * @param string $field_name
  *   The machine name of the field being processed.
  * @param string $field_type
  *   The type of field being handled.
  * @param string $column_name
  *   For fields containing multiple columns, the column name being processed.
  * @param string $column_type
  *   Within the field, the column type being handled.
  * @param bool $first
  *   TRUE if this is the first column within the field.
  * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
  *   The field definition.
  *
  * @return array
  *   The modified views data field definition.
  */
 protected function mapSingleFieldViewsData($table, $field_name, $field_type, $column_name, $column_type, $first, FieldDefinitionInterface $field_definition)
 {
     $views_field = array();
     // Provide a nicer, less verbose label for the first column within a field.
     // @todo Introduce concept of the "main" column for a field, rather than
     //   assuming the first one is the main column.
     if ($first) {
         $views_field['title'] = $field_definition->getLabel();
     } else {
         $views_field['title'] = $field_definition->getLabel() . " ({$column_name})";
     }
     if ($description = $field_definition->getDescription()) {
         $views_field['help'] = $description;
     }
     // Set up the field, sort, argument, and filters, based on
     // the column and/or field data type.
     // @todo Allow field types to customize this.
     // @see https://www.drupal.org/node/2337515
     switch ($field_type) {
         // Special case a few field types.
         case 'timestamp':
         case 'created':
         case 'changed':
             $views_field['field']['id'] = 'date';
             $views_field['argument']['id'] = 'date';
             $views_field['filter']['id'] = 'date';
             $views_field['sort']['id'] = 'date';
             break;
         case 'language':
             $views_field['field']['id'] = 'field';
             $views_field['argument']['id'] = 'language';
             $views_field['filter']['id'] = 'language';
             $views_field['sort']['id'] = 'standard';
             break;
         case 'boolean':
             $views_field['field']['id'] = 'field';
             $views_field['argument']['id'] = 'numeric';
             $views_field['filter']['id'] = 'boolean';
             $views_field['sort']['id'] = 'standard';
             break;
         case 'uri':
             // Let's render URIs as URIs by default, not links.
             $views_field['field']['id'] = 'field';
             $views_field['field']['default_formatter'] = 'string';
             $views_field['argument']['id'] = 'string';
             $views_field['filter']['id'] = 'string';
             $views_field['sort']['id'] = 'standard';
             break;
         case 'text':
         case 'text_with_summary':
             // Treat these three long text fields the same.
             $field_type = 'text_long';
             // Intentional fall-through here to the default processing!
         // Intentional fall-through here to the default processing!
         default:
             // For most fields, the field type is generic enough to just use
             // the column type to determine the filters etc.
             switch ($column_type) {
                 case 'int':
                 case 'integer':
                 case 'smallint':
                 case 'tinyint':
                 case 'mediumint':
                 case 'float':
                 case 'double':
                 case 'decimal':
                     $views_field['field']['id'] = 'field';
                     $views_field['argument']['id'] = 'numeric';
                     $views_field['filter']['id'] = 'numeric';
                     $views_field['sort']['id'] = 'standard';
                     break;
                 case 'char':
                 case 'string':
                 case 'varchar':
                 case 'tinytext':
                 case 'text':
                 case 'mediumtext':
                 case 'longtext':
                     $views_field['field']['id'] = 'field';
//.........这里部分代码省略.........
开发者ID:brstde,项目名称:gap1,代码行数:101,代码来源:EntityViewsData.php

示例4: getFilteredDescription

 /**
  * Returns the filtered field description.
  *
  * @return \Drupal\Core\Field\FieldFilteredMarkup
  *   The filtered field description, with tokens replaced.
  */
 protected function getFilteredDescription()
 {
     return FieldFilteredMarkup::create(\Drupal::token()->replace($this->fieldDefinition->getDescription()));
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:10,代码来源:WidgetBase.php


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