protected function MigratePluginAlterer::alterFieldMigrations in Media Migration 8
Alters field migrations from file_entity/media in 7 to media in 8.
Parameters
array $migrations: The array of migration plugins.
Throws
\Drupal\Component\Plugin\Exception\PluginException If a plugin cannot be found.
1 call to MigratePluginAlterer::alterFieldMigrations()
- MigratePluginAlterer::alter in src/
MigratePluginAlterer.php - Alters migrate plugins.
File
- src/
MigratePluginAlterer.php, line 85
Class
- MigratePluginAlterer
- Service for performing migration plugin alterations.
Namespace
Drupal\media_migrationCode
protected function alterFieldMigrations(array &$migrations) {
foreach ($migrations as &$migration) {
// If this is not a Drupal 7 migration, we can skip processing it.
if (!in_array('Drupal 7', $migration['migration_tags'] ?? [])) {
continue;
}
$source = NULL;
if (!empty($migration['source']['plugin'])) {
$source = MigrationPluginTool::getSourcePlugin($migration['source']);
if (is_a($migration['class'], FieldMigration::class, TRUE)) {
// Field storage, instance, widget and formatter migrations.
if (is_a($source, Field::class) || is_a($source, FieldInstance::class)) {
static::mapMigrationProcessValueToMedia($migration, 'entity_type');
}
}
// View Modes.
if (is_a($source, ViewMode::class)) {
static::mapMigrationProcessValueToMedia($migration, 'targetEntityType');
}
// D7 field instance migrations should have optional dependency on
// media types — just like it already does for node type, comment type
// and vocabulary type in core.
if ($migration['source']['plugin'] === 'd7_field_instance') {
$migration['migration_dependencies']['optional'][] = 'd7_file_entity_type';
}
}
}
}