Allow overriding id map migrate plugin

Created on 14 February 2018, over 6 years ago
Updated 21 February 2023, over 1 year ago

Problem/Motivation

Many migrate plugins are directly exposed on the yml files, so they can be overridden.
Id map migrate plugins are not exposed from migrate plus.

Here is one use case. I have a D6 or D7 site that creates Article nodes from a feed, using the Feeds module. When I migrate the site to D8, I want to create Article nodes from two sources:

  1. Migrate Articles from the existing site.
  2. Continue to import Articles from the feed.

In order to make sure that I do not import the same article twice (once from each source), I would like to use the same mapping table for both sources. The mapping table is defined by the Id map plugin, so I would like to be able to specify that in my migration.

Proposed resolution

Expose the Id map in the migration config, i.e. change the schema.

Once the idMap key is added to a migration, it is used in the core Migration object: see core/modules/migrate/src/Plugin/Migration.php:

  public function __construct(/* ... */) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    // ...

    foreach (NestedArray::mergeDeep($plugin_definition, $configuration) as $key => $value) {
      $this->$key = $value;
    }

  // ...

  public function getIdMap() {
    if (!isset($this->idMapPlugin)) {
      $configuration = $this->idMap;
      $plugin = isset($configuration['plugin']) ? $configuration['plugin'] : 'sql';
      $this->idMapPlugin = $this->idMapPluginManager->createInstance($plugin, $configuration, $this);
    }
    return $this->idMapPlugin;
  }

Completed tasks

  • Write a patch

Remaining tasks

  • Update the documentation.

User interface changes

N.A.

API changes

The idMap key is allowed on the root level of a migrate_plus.migration.* config object.

Data model changes

N.A.

✨ Feature request
Status

Needs review

Version

5.0

Component

API

Created by

πŸ‡΅πŸ‡ͺPeru marvil07

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024