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


PHP FieldTypePluginManagerInterface::getDefinition方法代码示例

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


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

示例1: calculateDependencies

 /**
  * {@inheritdoc}
  */
 public function calculateDependencies()
 {
     $this->dependencies = parent::calculateDependencies();
     // Add a dependency on the module that provides the field type using the
     // source plugin configuration.
     $source_configuration = $this->migration->get('source');
     if (isset($source_configuration['constants']['type'])) {
         $field_type = $this->fieldTypePluginManager->getDefinition($source_configuration['constants']['type']);
         $this->addDependency('module', $field_type['provider']);
     }
     return $this->dependencies;
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:15,代码来源:EntityFieldStorageConfig.php

示例2: prepareConfiguration

 /**
  * Merges default values for widget configuration.
  *
  * @param string $field_type
  *   The field type.
  * @param array $configuration
  *   An array of widget configuration.
  *
  * @return array
  *   The display properties with defaults added.
  */
 public function prepareConfiguration($field_type, array $configuration)
 {
     // Fill in defaults for missing properties.
     $configuration += array('settings' => array(), 'third_party_settings' => array());
     // If no widget is specified, use the default widget.
     if (!isset($configuration['type'])) {
         $field_type = $this->fieldTypeManager->getDefinition($field_type);
         $configuration['type'] = $field_type['default_widget'];
     }
     // Fill in default settings values for the widget.
     $configuration['settings'] += $this->getDefaultSettings($configuration['type']);
     return $configuration;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:24,代码来源:WidgetPluginManager.php

示例3: prepareConfiguration

 /**
  * Merges default values for formatter configuration.
  *
  * @param string $field_type
  *   The field type.
  * @param array $configuration
  *   An array of formatter configuration.
  *
  * @return array
  *   The display properties with defaults added.
  */
 public function prepareConfiguration($field_type, array $configuration)
 {
     // Fill in defaults for missing properties.
     $configuration += array('label' => 'above', 'settings' => array(), 'third_party_settings' => array());
     // If no formatter is specified, use the default formatter.
     if (!isset($configuration['type'])) {
         $field_type = $this->fieldTypeManager->getDefinition($field_type);
         $configuration['type'] = $field_type['default_formatter'];
     }
     // Filter out unknown settings, and fill in defaults for missing settings.
     $default_settings = $this->getDefaultSettings($configuration['type']);
     $configuration['settings'] = array_intersect_key($configuration['settings'], $default_settings) + $default_settings;
     return $configuration;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:25,代码来源:FormatterPluginManager.php

示例4: getFieldTypeDefinition

 /**
  * Gets field type definition.
  *
  * @return array
  *   The field type definition.
  */
 protected function getFieldTypeDefinition()
 {
     return $this->fieldTypeManager->getDefinition($this->getFieldStorageDefinition()->getType());
 }
开发者ID:Wylbur,项目名称:gj,代码行数:10,代码来源:EntityField.php

示例5: defineOptions

 /**
  * {@inheritdoc}
  */
 protected function defineOptions()
 {
     $options = parent::defineOptions();
     $field_storage_definition = $this->getFieldStorageDefinition();
     $field_type = $this->fieldTypePluginManager->getDefinition($field_storage_definition->getType());
     $column_names = array_keys($field_storage_definition->getColumns());
     $default_column = '';
     // Try to determine a sensible default.
     if (count($column_names) == 1) {
         $default_column = $column_names[0];
     } elseif (in_array('value', $column_names)) {
         $default_column = 'value';
     }
     // If the field has a "value" column, we probably need that one.
     $options['click_sort_column'] = array('default' => $default_column);
     if (isset($this->definition['default_formatter'])) {
         $options['type'] = ['default' => $this->definition['default_formatter']];
     } elseif (isset($field_type['default_formatter'])) {
         $options['type'] = ['default' => $field_type['default_formatter']];
     } else {
         $options['type'] = ['default' => ''];
     }
     $options['settings'] = array('default' => isset($this->definition['default_formatter_settings']) ? $this->definition['default_formatter_settings'] : []);
     $options['group_column'] = array('default' => $default_column);
     $options['group_columns'] = array('default' => array());
     // Options used for multiple value fields.
     $options['group_rows'] = array('default' => TRUE);
     // If we know the exact number of allowed values, then that can be
     // the default. Otherwise, default to 'all'.
     $options['delta_limit'] = array('default' => $field_storage_definition->getCardinality() > 1 ? $field_storage_definition->getCardinality() : 0);
     $options['delta_offset'] = array('default' => 0);
     $options['delta_reversed'] = array('default' => FALSE);
     $options['delta_first_last'] = array('default' => FALSE);
     $options['multi_type'] = array('default' => 'separator');
     $options['separator'] = array('default' => ', ');
     $options['field_api_classes'] = array('default' => FALSE);
     return $options;
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:41,代码来源:Field.php

示例6: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $error = FALSE;
     $values = $form_state->getValues();
     $destinations = array();
     $entity_type = $this->entityManager->getDefinition($this->entityTypeId);
     // Create new field.
     if ($values['new_storage_type']) {
         $field_storage_values = ['field_name' => $values['field_name'], 'entity_type' => $this->entityTypeId, 'type' => $values['new_storage_type'], 'translatable' => $values['translatable']];
         $field_values = ['field_name' => $values['field_name'], 'entity_type' => $this->entityTypeId, 'bundle' => $this->bundle, 'label' => $values['label'], 'translatable' => FALSE];
         $widget_id = $formatter_id = NULL;
         // Check if we're dealing with a preconfigured field.
         if (strpos($field_storage_values['type'], 'field_ui:') !== FALSE) {
             list(, $field_type, $option_key) = explode(':', $field_storage_values['type'], 3);
             $field_storage_values['type'] = $field_type;
             $field_type_class = $this->fieldTypePluginManager->getDefinition($field_type)['class'];
             $field_options = $field_type_class::getPreconfiguredOptions()[$option_key];
             // Merge in preconfigured field storage options.
             if (isset($field_options['field_storage_config'])) {
                 foreach (array('cardinality', 'settings') as $key) {
                     if (isset($field_options['field_storage_config'][$key])) {
                         $field_storage_values[$key] = $field_options['field_storage_config'][$key];
                     }
                 }
             }
             // Merge in preconfigured field options.
             if (isset($field_options['field_config'])) {
                 foreach (array('required', 'settings') as $key) {
                     if (isset($field_options['field_config'][$key])) {
                         $field_values[$key] = $field_options['field_config'][$key];
                     }
                 }
             }
             $widget_id = isset($field_options['entity_form_display']['type']) ? $field_options['entity_form_display']['type'] : NULL;
             $formatter_id = isset($field_options['entity_view_display']['type']) ? $field_options['entity_view_display']['type'] : NULL;
         }
         // Create the field storage and field.
         try {
             $this->entityManager->getStorage('field_storage_config')->create($field_storage_values)->save();
             $field = $this->entityManager->getStorage('field_config')->create($field_values);
             $field->save();
             $this->configureEntityFormDisplay($values['field_name'], $widget_id);
             $this->configureEntityViewDisplay($values['field_name'], $formatter_id);
             // Always show the field settings step, as the cardinality needs to be
             // configured for new fields.
             $route_parameters = array('field_config' => $field->id()) + FieldUI::getRouteBundleParameter($entity_type, $this->bundle);
             $destinations[] = array('route_name' => "entity.field_config.{$this->entityTypeId}_storage_edit_form", 'route_parameters' => $route_parameters);
             $destinations[] = array('route_name' => "entity.field_config.{$this->entityTypeId}_field_edit_form", 'route_parameters' => $route_parameters);
             $destinations[] = array('route_name' => "entity.{$this->entityTypeId}.field_ui_fields", 'route_parameters' => $route_parameters);
             // Store new field information for any additional submit handlers.
             $form_state->set(['fields_added', '_add_new_field'], $values['field_name']);
         } catch (\Exception $e) {
             $error = TRUE;
             drupal_set_message($this->t('There was a problem creating field %label: @message', array('%label' => $values['label'], '@message' => $e->getMessage())), 'error');
         }
     }
     // Re-use existing field.
     if ($values['existing_storage_name']) {
         $field_name = $values['existing_storage_name'];
         try {
             $field = $this->entityManager->getStorage('field_config')->create(array('field_name' => $field_name, 'entity_type' => $this->entityTypeId, 'bundle' => $this->bundle, 'label' => $values['existing_storage_label']));
             $field->save();
             $this->configureEntityFormDisplay($field_name);
             $this->configureEntityViewDisplay($field_name);
             $route_parameters = array('field_config' => $field->id()) + FieldUI::getRouteBundleParameter($entity_type, $this->bundle);
             $destinations[] = array('route_name' => "entity.field_config.{$this->entityTypeId}_field_edit_form", 'route_parameters' => $route_parameters);
             $destinations[] = array('route_name' => "entity.{$this->entityTypeId}.field_ui_fields", 'route_parameters' => $route_parameters);
             // Store new field information for any additional submit handlers.
             $form_state->set(['fields_added', '_add_existing_field'], $field_name);
         } catch (\Exception $e) {
             $error = TRUE;
             drupal_set_message($this->t('There was a problem creating field %label: @message', array('%label' => $values['label'], '@message' => $e->getMessage())), 'error');
         }
     }
     if ($destinations) {
         $destination = $this->getDestinationArray();
         $destinations[] = $destination['destination'];
         $form_state->setRedirectUrl(FieldUI::getNextDestination($destinations, $form_state));
     } elseif (!$error) {
         drupal_set_message($this->t('Your settings have been saved.'));
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:85,代码来源:FieldStorageAddForm.php


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