On this page
Overview of migrate field plugins
Last updated on
11 March 2021
This documentation needs work. See "Help improve this page" in the sidebar.
Field plugins provide a direct upgrade solution from Drupal 6/7 fields to Drupal 8/9 equivalents. They are responsible for handling the migration of custom fields and add processes to migrations for entities that have fields.
When you write custom migrate field plugins they:
- usually extend Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase.
- must be annotated with \Drupal\migrate_drupal\Annotation\MigrateField.
- must be in the namespace sub directory Plugin\migrate\field under the namespace of the module that defines them, for example
MYMODULE/src/Plugin/migrate/field
. - must have class names end with Field, otherwise they will not be detected.
MigrateField example
The following example is the field plugin for Drupal 7 text fields.
@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",
)
MigrateField annotation
- The
id
property often matches the source field type. It does not in this example. - The
source_module
is the name of the module on the source site that provides the field type. - The
destination_module
is the name of the module on the destination Drupal 8/9 that provides the field type. - The
core
property is the Drupal version of the source site the provides the field type. If it the same for both Drupal 6 and Drupal 7 use {6, 7}. - The 'type_map' is an array in the format 'd6/d7_field_name' => 'd8/d9_field_name'.
Help improve this page
Page status: Needs work
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion