d8 migration plugins - drupalcon...d8 migrate in core background the migrate and drupal-to-drupal...

Post on 16-Jul-2020

10 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

D8 Migration PluginsMIKE ANELLO, RYAN WEAL, KEITH DECHANTW r i t i n g a C u s t o m M i g r a t i o n P l u g i n f o r D 8

Who are we?Mike Anello (ultimike)Keith Dechant (kdechant)Ryan Weal (Ryan Weal)

Who are you?Contrib module developers

Custom module developers

Migrate-curious

Oops, I'm in the wrong room!

D8 Migrate in Core BackgroundThe Migrate and Drupal-to-Drupal Data Migrationmodules have been rewritten and moved intoDrupal 8 core.Their scope has been expanded to supportmigration of content and configuration.

D8 Migrate in Core Backgroundcore/modules/migratecore/modules/migrate_drupal

D8 Migrate in Core StatusMost of the D6->D8 migration work is done - somebugs remain.The D7->D8 migration work is just getting started.The migration UI is not {yet} in core.Rollbacks and other advanced features not yet incore.

D8 Migrate in Core StatusSprint with us tomorrow and Saturday.#drupal-migrategroups.drupal.org/imp

Extensible! (Duh)The best part: D8 migration API is extensible.Leverages standard D8 plugins.Contrib/custom module authors will be able toprovide migration support for the content andconfiguration data their module manages.

Kinds of MigrationsVariable Migrations (relatively easy)

Field migrations

Entity-type migrations (more complex)

Others (?)

Kinds of MigrationsVariable Migrations (relatively easy)

Field migrations

Entity-type migrations (more complex)

Others (?)

Field Module MigrationsWhen we want to migrate a field (configurationand content), we actually need to run severalmigrations...

Field Module MigrationsLuckily, most of the time we only have to worryabout four of them...

What does a migration configurationlook like?

D6_FIELD.YMLsource (get the data)process (map fields and massage the data)destination (save the data)

What does a migration configuration

look like?

D6_FIELD.YML ­ SOURCE

What does a migration configuration

look like?

D6_FIELD.YML ­ PROCESS

(MAP AND MASSAGE) status: active field_name: field_name type: - plugin: static_map source: - type - widget_type map:

What does a migration configuration

look like?

D6_FIELD.YML ­

DESTINATIONdestination: plugin: entity:field_storage_config

Each of these migrations works the same way!

TaskCreate a migration plugin for the D6 Iframemodule.https://drupal.org/project/iframe

TaskWe're not going to demo porting the entiremodule.We're going to migrate D6 iframe fieldconfiguration and data to D8 Link fieldconfiguration and data.

TaskAll we have to do is add new configuration toexisting migrations.Why not modify configuration files directly?Why not write a separate migration for it?

Inform d6_field.yml about the iframe field type, d6_field_instance_widget_settings.yml about the iframewidget mapping, etc...

Plugins!A recent core commit(https://www.drupal.org/node/2448501) makes itpossible to define a new field migrations with aplugin.The abstract CckFieldPluginBase class providesthe basic functionality that we can expand on.CckFieldPluginBase implementsMigrateCckFieldInterface.

MigrateCckFieldInterface*processField - add field type mappings*processFieldInstance - add field instancemappings*processFieldWidget - add field widget mappings*processFieldFormatter - add field formattermappings

MigrateCckFieldInterface (continued)getFieldFormatterMap - defines the formattermap*getFieldWidgetMap - defines the widget mapprocessCckFieldValues - defines new processplugin

* implemented by abstract CckFieldPluginBase class

The PlanSubclass CckFieldPluginBaseWrite a custom process plugin to massage iframefield data into Link field data.

Code Walkthrough

https://www.drupal.org/sandbox/benjy/2422307

Future TasksPort the rest of the module?Create an iframe field formatter for Link field?

What did you think?EVALUATE THIS SESSION ­

EVENTS.DRUPAL.ORG/NODE/1011

THANK YOU!

top related