Provide migration path from Video module

Created on 6 May 2024, 8 months ago

Problem/Motivation

It would be useful to provide a migration path from the Video β†’ module to media entities.

Proposed resolution

Document how to migrate from the Video module.

Remaining tasks

Work out how to do the migration.

API changes

TBD

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @DamienMcKenna
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    The "Video" field type has two elements:

    • [fieldname]_fid - file ID of the video.
    • [fieldname]_thumbnail - file ID of the thumbnail.

    it should be easy to provide a migration plugin to map the field data.

  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    A starting point:

    
    namespace Drupal\media_migration\Plugin\migrate\field;
    
    use Drupal\migrate\Plugin\MigrationInterface;
    use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
    
    /**
     * @MigrateField(
     *   id = "video",
     *   core = {7},
     *   type_map = {
     *     "video" = "entity_reference",
     *   },
     *   source_module = "video",
     *   destination_module = "core",
     * )
     */
    class VideoItem extends FieldPluginBase {
    
      /**
       * {@inheritdoc}
       */
      public function getFieldWidgetMap() {
        return [
          'video_upload' => 'entity_reference',
        ];
      }
    
      /**
       * {@inheritdoc}
       */
      public function getFieldFormatterMap() {
        return [
          'video_formatter_player' => 'entity_reference_entity_view',
        ];
      }
    
      /**
       * {@inheritdoc}
       */
      public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) {
        $process = [
          'plugin' => 'sub_process',
          'source' => $field_name,
          'process' => [
            'target_id' => 'fid',
          ],
        ];
        $migration->mergeProcessOfProperty($field_name, $process);
      }
    
    }
    
Production build 0.71.5 2024