3

I'm doing a migration into D8, and I'm migrating into a custom video player field with multiple values. Here's the schema for the field as defined in its plugin:

  public static function schema(FieldStorageDefinitionInterface $field_definition) {
    return array(
      'columns' => array(
        'vid' => array(
          'type' => 'int',
          'size' => 'normal',
          'not null' => TRUE,
          'default' => 0,
        ),
        'video' => array(
          'type' => 'varchar',
          'length' => 256,
          'not null' => FALSE,
        ),
        'video_hd' => array(
          'type' => 'varchar',
          'length' => 256,
          'not null' => FALSE,
        ),
        'video_sm' => array(
          'type' => 'varchar',
          'length' => 256,
          'not null' => FALSE,
        ),
        'thumbnail' => array(
          'type' => 'varchar',
          'length' => 256,
          'not null' => FALSE,
        ),
        'poster' => array(
          'type' => 'varchar',
          'length' => 256,
          'not null' => FALSE,
        ),
        'show_ads' => array(
          'type' => 'int',
          'size' => 'tiny',
          'not null' => TRUE,
          'default' => '1',
        ),
        'raw_file' => array(
          'type' => 'varchar',
          'length' => 256,
          'not null' => FALSE,
        ),
      ),
    );
  }

I have a custom source plugin that gathers all of the information needed for these columns into appropriately named items. My question is, how do I get those pieces of data into the destination field. Can I do it in the .yml file configuration, as can be done with the body field?

  'body/format':
    plugin: migration
    migration: d6_filter_format
    source: format
  'body/value': node_body
  'body/summary': teaser

Or do I need to have a custom destination plugin that takes these pieces of data and puts them into the correct places in the node? I'm seeing a lot of blogs and documentation on source and process plugins, but not much on destination plugins, so I'm not sure.

Thanks.

1 Answer 1

0

Nothing to do with destination plugins, what you need to do would be in the process pipeline. You could write a custom process plugin like, say, d6_cck_link. Or, you can use the iterator process plugin - see, for example, how d6_upload.yml in core populates the target_id/display/description columns of the 'upload' field.

3
  • So I'm looking at d6_cck_link plugin (aka the CckLink class), and I see that it returns a $route array. Am I reading correctly that that array are the column values for the field, equivalent to the definitions in the schema definition in my question?
    – wonder95
    Commented Dec 10, 2016 at 1:08
  • Yep - you'll return an array with 'vid', 'video', 'video_hd' etc. keys.
    – Mike Ryan
    Commented Dec 11, 2016 at 16:35
  • Hmmm, ok, trying that but it isn't working (see here).
    – wonder95
    Commented Dec 13, 2016 at 23:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.