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
Same name and namespace in other branches
- 9 core/modules/text/src/Plugin/migrate/field/d7/TextField.php \Drupal\text\Plugin\migrate\field\d7\TextField
Plugin annotation
@MigrateField(
id = "d7_text",
type_map = {
"text" = "text",
"text_long" = "text_long",
"text_with_summary" = "text_with_summary"
},
core = {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\text\Plugin\migrate\field\d7\TextField
- class \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase implements MigrateFieldInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of TextField
1 file declares its use of TextField
- TextFieldTest.php in core/
modules/ text/ tests/ src/ Unit/ Plugin/ migrate/ field/ d7/ TextFieldTest.php
File
- core/
modules/ text/ src/ Plugin/ migrate/ field/ d7/ TextField.php, line 22
Namespace
Drupal\text\Plugin\migrate\field\d7View source
class TextField extends FieldPluginBase {
/**
* {@inheritdoc}
*/
public function getFieldFormatterType(Row $row) {
$field_type = $this
->getFieldType($row);
$formatter_type = $row
->getSourceProperty('formatter/type');
switch ($field_type) {
case 'string':
$formatter_type = str_replace([
'text_default',
'text_plain',
], 'string', $formatter_type);
break;
case 'string_long':
$formatter_type = str_replace('text_default', 'basic_string', $formatter_type);
break;
}
return $formatter_type;
}
/**
* {@inheritdoc}
*/
public function getFieldWidgetType(Row $row) {
$field_type = $this
->getFieldType($row);
$widget_type = $row
->getSourceProperty('widget/type');
switch ($field_type) {
case 'string':
$widget_type = str_replace('text_textfield', 'string_textfield', $widget_type);
break;
case 'string_long':
$widget_type = str_replace('text_textarea', 'string_textarea', $widget_type);
break;
}
return $widget_type;
}
/**
* {@inheritdoc}
*/
public function getFieldType(Row $row) {
$type = $row
->getSourceProperty('type');
$plain_text = FALSE;
$filtered_text = FALSE;
foreach ($row
->getSourceProperty('instances') as $instance) {
// Check if this field has plain text instances, filtered text instances,
// or both.
$data = unserialize($instance['data']);
switch ($data['settings']['text_processing']) {
case '0':
$plain_text = TRUE;
break;
case '1':
$filtered_text = TRUE;
break;
}
}
if (in_array($type, [
'text',
'text_long',
])) {
// If a text or text_long field has only plain text instances, migrate it
// to a string or string_long field.
if ($plain_text && !$filtered_text) {
$type = str_replace([
'text',
'text_long',
], [
'string',
'string_long',
], $type);
}
elseif ($plain_text && $filtered_text) {
$field_name = $row
->getSourceProperty('field_name');
throw new MigrateSkipRowException("Can't migrate source field {$field_name} configured with both plain text and filtered text processing. See https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#plain-text");
}
}
elseif ($type == 'text_with_summary' && $plain_text) {
// If a text_with_summary field has plain text instances, skip the row
// since there's no such thing as a string_with_summary field.
$field_name = $row
->getSourceProperty('field_name');
throw new MigrateSkipRowException("Can't migrate source field {$field_name} of type text_with_summary configured with plain text processing. See https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#plain-text");
}
return $type;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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 |
Apply any custom processing to the field bundle migrations. Overrides MigrateFieldInterface:: |
11 |
FieldPluginBase:: |
public | function |
Get a map between D6 formatters and D8 formatters for this field type. Overrides MigrateFieldInterface:: |
12 |
FieldPluginBase:: |
public | function |
Get a map between D6 and D8 widgets for this field type. Overrides MigrateFieldInterface:: |
10 |
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 the field formatter type from the source. Overrides FieldPluginBase:: |
|
TextField:: |
public | function |
Computes the destination type of a migrated field. Overrides FieldPluginBase:: |
|
TextField:: |
public | function |
Get the field widget type from the source. Overrides FieldPluginBase:: |