migration – Paragraphs of sub_process

You can also create a process plug-in to create the online paragraph with the record that you are migrating. I can not do fragmented migrations for every room, and in my case, I can not. The project has about 100,000 nodes and no data structure to create paragraphs. Even if I could, I do not want to have to run as many times to get a complete set of data.

Anyway.

Here is a real example:

createParagraphItem ($ item);
}

returns $ paragraphs;
}

/ **
* {@inheritdoc}
* /
multiple public function (): bool {
return TRUE;
}

/ **
* Generates a paragraph element entity.
*
* @param array $ value
* @return array
* @throws  Drupal  Core  Entity  EntityStorageException
* @throws  Drupal  migrate  MigrateException
* /
Protected function createParagraphItem (array $ value): array {
$ paragraph = Paragraph :: create ([
      'type' => 'paper_authors',
      'field_paper_author' => [
        'target_id'  =>  $value['user_id'],
],
& # 39; field_paper_paper_published_name & # 39; => [
        'value'  =>  $value['name'],
],
& # 39; field_paper_disclosure & # 39; => [
        'value'  =>  $value['disclosure'],
& # 39; size & # 39; => & # 39; basic_html & # 39;
],
])

$ paragraph-> save ();

return [
      'target_id' => $paragraph->id(),
      'target_revision_id' => $paragraph->getRevisionId(),
    ];
}
}

In my yaml migration definition:

        _authors_shim:
plugin: generate_authors_array
source: author_array
field_paper_published_authors:
plugin: published_author_gement_item
source: @_ authors_shim & # 39;

generate_authors_array is another process plugin that I use to massage the plugin code data above. This type of paragraph has a user reference, a plain text field, and a long text field. The value passed is an array of tables. This will create several paragraph deltas for the paragraph field that I fill. He is also coming back correctly.

I had tried to make this work with subprocess at first, but I could not have the paragraph field populated until I went that way. I believe this is due to paragraphs that contain references to their stored entities (target_id, target_revision_id).