class TextField in Drupal 8
Same name in this branch
- 8 core/modules/config_translation/src/FormElement/Textfield.php \Drupal\config_translation\FormElement\Textfield
- 8 core/lib/Drupal/Core/Render/Element/Textfield.php \Drupal\Core\Render\Element\Textfield
- 8 core/modules/text/src/Plugin/migrate/cckfield/TextField.php \Drupal\text\Plugin\migrate\cckfield\TextField
- 8 core/modules/text/src/Plugin/migrate/field/d6/TextField.php \Drupal\text\Plugin\migrate\field\d6\TextField
- 8 core/modules/text/src/Plugin/migrate/field/d7/TextField.php \Drupal\text\Plugin\migrate\field\d7\TextField
Plugin annotation
@MigrateCckField(
id = "text",
type_map = {
"text" = "text",
"text_long" = "text_long",
"text_with_summary" = "text_with_summary"
},
core = {6,7},
source_module = "text",
destination_module = "text",
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase implements MigrateFieldInterface
- class \Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase implements MigrateCckFieldInterface
- class \Drupal\text\Plugin\migrate\cckfield\TextField
- class \Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase implements MigrateCckFieldInterface
- class \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase implements MigrateFieldInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of TextField
Deprecated
in drupal:8.3.0 and is removed from drupal:9.0.0. Use \Drupal\text\Plugin\migrate\field\d6\TextField or \Drupal\text\Plugin\migrate\field\d7\TextField instead.
See also
https://www.drupal.org/node/2751897
2 files declare their use of TextField
- TextCckTest.php in core/
modules/ text/ tests/ src/ Unit/ Migrate/ TextCckTest.php - TextCckTest.php in core/
modules/ text/ tests/ src/ Unit/ Plugin/ migrate/ cckfield/ TextCckTest.php
File
- core/
modules/ text/ src/ Plugin/ migrate/ cckfield/ TextField.php, line 30
Namespace
Drupal\text\Plugin\migrate\cckfieldView source
class TextField extends CckFieldPluginBase {
/**
* {@inheritdoc}
*/
public function getFieldWidgetMap() {
return [
'text_textfield' => 'text_textfield',
];
}
/**
* {@inheritdoc}
*/
public function getFieldFormatterMap() {
return [
'default' => 'text_default',
'trimmed' => 'text_trimmed',
'plain' => 'basic_string',
];
}
/**
* {@inheritdoc}
*/
public function processCckFieldValues(MigrationInterface $migration, $field_name, $field_info) {
$widget_type = isset($field_info['widget_type']) ? $field_info['widget_type'] : $field_info['widget']['type'];
if ($widget_type == 'optionwidgets_onoff') {
$process = [
'value' => [
'plugin' => 'static_map',
'source' => 'value',
'default_value' => 0,
],
];
$checked_value = explode("\n", $field_info['global_settings']['allowed_values'])[1];
if (strpos($checked_value, '|') !== FALSE) {
$checked_value = substr($checked_value, 0, strpos($checked_value, '|'));
}
$process['value']['map'][$checked_value] = 1;
}
else {
// See \Drupal\migrate_drupal\Plugin\migrate\source\d6\User::baseFields(),
// signature_format for an example of the YAML that represents this
// process array.
$process = [
'value' => 'value',
'format' => [
[
'plugin' => 'static_map',
'bypass' => TRUE,
'source' => 'format',
'map' => [
0 => NULL,
],
],
[
'plugin' => 'skip_on_empty',
'method' => 'process',
],
[
'plugin' => 'migration',
'migration' => [
'd6_filter_format',
'd7_filter_format',
],
'source' => 'format',
],
],
];
}
$process = [
'plugin' => 'sub_process',
'source' => $field_name,
'process' => $process,
];
$migration
->setProcessOfProperty($field_name, $process);
}
/**
* {@inheritdoc}
*/
public function getFieldType(Row $row) {
$widget_type = $row
->getSourceProperty('widget_type');
$settings = $row
->getSourceProperty('global_settings');
if ($widget_type == 'text_textfield') {
$field_type = $settings['text_processing'] ? 'text' : 'string';
if (empty($settings['max_length']) || $settings['max_length'] > 255) {
$field_type .= '_long';
}
return $field_type;
}
if ($widget_type == 'text_textarea') {
$field_type = $settings['text_processing'] ? 'text_long' : 'string_long';
return $field_type;
}
switch ($widget_type) {
case 'optionwidgets_buttons':
case 'optionwidgets_select':
return 'list_string';
case 'optionwidgets_onoff':
return 'boolean';
default:
return parent::getFieldType($row);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CckFieldPluginBase:: |
public | function |
Apply any custom processing to the field bundle migrations. Overrides FieldPluginBase:: |
|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FieldPluginBase:: |
public | function |
Apply any custom processing to the field formatter migration. Overrides MigrateFieldInterface:: |
|
FieldPluginBase:: |
public | function |
Apply any custom processing to the field instance migration. Overrides MigrateFieldInterface:: |
2 |
FieldPluginBase:: |
public | function |
Apply any custom processing to the field migration. Overrides MigrateFieldInterface:: |
|
FieldPluginBase:: |
public | function |
Apply any custom processing to the field widget migration. Overrides MigrateFieldInterface:: |
|
FieldPluginBase:: |
public | function |
Get the field formatter type from the source. Overrides MigrateFieldInterface:: |
1 |
FieldPluginBase:: |
public | function |
Get the field widget type from the source. Overrides MigrateFieldInterface:: |
1 |
FieldPluginBase:: |
public | function | Alters the migration for field definitions. | |
FieldPluginBase:: |
public | function | Alter field formatter migration. | |
FieldPluginBase:: |
public | function | Alert field instance migration. | |
FieldPluginBase:: |
public | function | Defines the process pipeline for field values. | |
FieldPluginBase:: |
public | function | Alter field widget migration. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
TextField:: |
public | function |
Get a map between D6 formatters and D8 formatters for this field type. Overrides FieldPluginBase:: |
|
TextField:: |
public | function |
Computes the destination type of a migrated field. Overrides FieldPluginBase:: |
|
TextField:: |
public | function |
Get a map between D6 and D8 widgets for this field type. Overrides FieldPluginBase:: |
|
TextField:: |
public | function |
Apply any custom processing to the field bundle migrations. Overrides CckFieldPluginBase:: |