You are here

public function Fallback::prepareMediaSourceFieldFormatterRow in Media Migration 8

Overrides MediaDealerBase::prepareMediaSourceFieldFormatterRow

File

src/Plugin/media_migration/file/Fallback.php, line 111

Class

Fallback
General plugin for any kind of file.

Namespace

Drupal\media_migration\Plugin\media_migration\file

Code

public function prepareMediaSourceFieldFormatterRow(Row $row, Connection $connection) : void {
  parent::prepareMediaSourceFieldFormatterRow($row, $connection);
  $original_options = $row
    ->getSourceProperty('options') ?? [];
  switch ($this
    ->getDestinationMediaSourcePluginId()) {
    case 'audio_file':
      $options = [
        'type' => 'file_audio',
        'settings' => [
          'controls' => TRUE,
          'autoplay' => FALSE,
          'loop' => FALSE,
          'multiple_file_display_type' => 'tags',
        ],
      ] + $original_options;
      $row
        ->setSourceProperty('options', $options);
      break;
    case 'video_file':
      $options = [
        'type' => 'file_video',
        'settings' => [
          'muted' => FALSE,
          'width' => 640,
          'height' => 480,
        ],
      ] + $original_options;
      $row
        ->setSourceProperty('options', $options);
      break;
    case 'image':
      $original_options['settings'] = [
        'image_style' => 'large',
      ];
      $row
        ->setSourceProperty('options', $original_options);
      break;
  }
}