You are here

private function MediaMigrationSubscriber::imageFieldToMedia in Media Migration 8

Migrates image fields to media image fields.

Changes the type from image to media_image so it can be processed by a migrate field plugin.

Parameters

\Drupal\migrate_plus\Event\MigratePrepareRowEvent $event: The prepare row event.

Throws

\Exception If the row is empty.

See also

\Drupal\media_migration\Plugin\migrate\field\MediaImage

1 call to MediaMigrationSubscriber::imageFieldToMedia()
MediaMigrationSubscriber::onPrepareRow in src/EventSubscriber/MediaMigrationSubscriber.php
Migrate prepare row event handler.

File

src/EventSubscriber/MediaMigrationSubscriber.php, line 140

Class

MediaMigrationSubscriber
Media migration event subscriber.

Namespace

Drupal\media_migration\EventSubscriber

Code

private function imageFieldToMedia(MigratePrepareRowEvent $event) {
  if (in_array($event
    ->getSource()
    ->getPluginId(), [
    'd7_field',
    'd7_field_instance',
    'd7_field_instance_per_view_mode',
    'd7_field_instance_per_form_display',
    'd7_view_mode',
  ])) {
    $row = $event
      ->getRow();
    if ($row
      ->getSourceProperty('type') == 'image') {
      $row
        ->setSourceProperty('type', 'media_image');
    }
  }
}