You are here

public function MediaImage::defineValueProcessPipeline in Media Migration 8

Apply any custom processing to the field bundle migrations.

Parameters

\Drupal\migrate\Plugin\MigrationInterface $migration: The migration entity.

string $field_name: The field name we're processing the value for.

array $data: The array of field data from FieldValues::fieldData().

Overrides FieldPluginBase::defineValueProcessPipeline

File

src/Plugin/migrate/field/MediaImage.php, line 53

Class

MediaImage
Field Plugin for image field to media image field migrations.

Namespace

Drupal\media_migration\Plugin\migrate\field

Code

public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) {

  // The "media_migration_delta_sort" plugin sorts field values for PostgreSQL
  // sources.
  // @see \Drupal\media_migration\Plugin\migrate\process\MediaMigrationDeltaSort
  // @todo remove when https://drupal.org/i/3164520 is fixed.
  $process = [
    [
      'plugin' => 'media_migration_delta_sort',
      'source' => $field_name,
    ],
  ];
  $process[] = [
    'plugin' => 'sub_process',
    'process' => [
      'target_id' => 'fid',
    ],
  ];
  $migration
    ->setProcessOfProperty($field_name, $process);

  // Add image media migrations as required dependencies.
  $migration_dependencies = $migration
    ->getMigrationDependencies();
  $migration_dependencies['required'] = array_unique(array_merge(array_values($migration_dependencies['required']), [
    'd7_file_plain:image',
    'd7_file_entity:image',
  ]));
  $migration
    ->set('migration_dependencies', $migration_dependencies);
}