You are here

public static function MigratePluginAlterer::mapMigrationProcessValueToMedia in Media Migration 8

Maps a migration's property from "file" to "media".

Parameters

array $migration: The migration to alter.

string $property: The property to change.

1 call to MigratePluginAlterer::mapMigrationProcessValueToMedia()
MigratePluginAlterer::alterFieldMigrations in src/MigratePluginAlterer.php
Alters field migrations from file_entity/media in 7 to media in 8.

File

src/MigratePluginAlterer.php, line 245

Class

MigratePluginAlterer
Service for performing migration plugin alterations.

Namespace

Drupal\media_migration

Code

public static function mapMigrationProcessValueToMedia(array &$migration, string $property) {
  if (!empty($migration['source'][__FUNCTION__])) {
    return;
  }
  try {
    $value = static::getSourceValueOfMigrationProcess($migration, $property);
    switch ($value) {
      case 'file':
        $migration['source']["media_migration_{$property}"] = 'media';
        $migration['process'][$property] = "media_migration_{$property}";
        break;
      case NULL:

        // The value of the property cannot be determined, it might be a
        // dynamic value.
        $entity_type_process = MigrationPluginTool::getAssociativeMigrationProcess($migration['process'][$property]);
        $entity_type_process[] = [
          'plugin' => 'static_map',
          'map' => [
            'file' => 'media',
          ],
          'bypass' => TRUE,
        ];
        $migration['process'][$property] = $entity_type_process;
        break;
    }
  } catch (\LogicException $e) {

    // The process property does not exists, nothing to do.
  }
  $migration['source'][__FUNCTION__] = TRUE;
}