protected function MigratePluginAlterer::alterFilterFormatMigration in Media Migration 8
Maps Drupal 7 media_filter filter plugin to a Drupal 8|9 filter plugin.
If Entity Embed module is installed on the destination site, this method maps the media_embed filter plugin (Drupal 7 Media WYSIWYG module) to entity_embed filter plugin (from the Entity Embed module). If Entity Embed is unavailable, the media_filter filter will be mapped to media_embed filter (from core Media Library module).
Parameters
array $migrations: The array of migration plugins.
1 call to MigratePluginAlterer::alterFilterFormatMigration()
- MigratePluginAlterer::alter in src/
MigratePluginAlterer.php - Alters migrate plugins.
File
- src/
MigratePluginAlterer.php, line 205
Class
- MigratePluginAlterer
- Service for performing migration plugin alterations.
Namespace
Drupal\media_migrationCode
protected function alterFilterFormatMigration(array &$migrations) : void {
$destination_filter_plugin_id = MediaMigration::getEmbedTokenDestinationFilterPlugin();
// If entity_embed is not installed, the destination entity type of the
// "d7_embed_button_media" migration is missing.
if (!$this->moduleHandler
->moduleExists('entity_embed')) {
unset($migrations['d7_embed_button_media']);
}
if (isset($migrations['d7_filter_format']) && MediaMigration::embedTokenDestinationFilterPluginIsValid($destination_filter_plugin_id)) {
$migrations['d7_filter_format']['process']['filters']['process']['id']['map']['media_filter'] = $destination_filter_plugin_id;
}
else {
// We don't know the transform type or the filter format migration does
// not exist.
return;
}
if (MediaMigration::MEDIA_TOKEN_DESTINATION_FILTER_ENTITY_EMBED == $destination_filter_plugin_id && isset($migrations['d7_filter_format']) && isset($migrations['d7_embed_button_media'])) {
$migrations['d7_filter_format']['migration_dependencies']['required'][] = 'd7_embed_button_media';
}
// We have to add <drupal-entity> or <drupal-media> to the allowed html
// tag's list.
if (isset($migrations['d7_filter_format'])) {
$filter_plugin_settings_processes = MigrationPluginTool::getAssociativeMigrationProcess($migrations['d7_filter_format']['process']['filters']['process']['settings']);
$filter_plugin_settings_processes[] = [
'plugin' => 'filter_settings_embed_media',
];
$migrations['d7_filter_format']['process']['filters']['process']['settings'] = $filter_plugin_settings_processes;
}
}