[PP-1] Migrate plugin base classes should implement ConfigurablePluginInterface

Created on 16 January 2018, almost 7 years ago
Updated 18 July 2024, 3 months ago

Problem/Motivation

Migration plugins throughout core and contrib keep having to do this sort of thing:

$delimiter = isset($this->configuration['delimiter']) ? $this->configuration['delimiter'] : '';

Proposed resolution

Implementing https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Component%21Plug... means that plugins can define default values for any configuration in defaultConfiguration().

The result is:
- better DX as you don't have to keep checking array values in $this->configuration are defined
- better DX as the default value for something in $this->configuration is in one place only
- better DX as there's a place where all the configuration options for the class are listed (well the class docs should have that too... but it nudges modules that are lax on docs towards listing them)

This can be done in SourcePluginBase, ProcessPluginBase, & DestinationBase.

To facilitate this, create an @internal ConfigurablePluginTrait in the migrate module to use with migration base plugins. There is discussion to do this in the core plugin system in πŸ“Œ Create a trait and base class to implement \Drupal\Component\Plugin\ConfigurableInterface Needs review , however for the migration plugins we want to prevent use of the calculateDependencies method from the interface, as these plugins are not configurations and do not use dependencies. Depending on the outcome of that issue and #2946122: Deprecate ConfigurablePluginInterface and replace with an interface that doesn't extend DependentPluginInterface β†’ there may be a future core plugin library solution to address this, and refactoring the migration plugins around a module trait now will make that process much easier, and provide immediate benefits in cleaning up the plugin code. Making the trait @internal will make sure we can refactor around any potential plugin library solution in the future.

Remaining tasks

Postponed on πŸ“Œ Create a trait and base class to implement \Drupal\Component\Plugin\ConfigurableInterface Needs review

Commit it!
As a follow up to this issue, refactor plugins to set default configurations and remove unnecessary isset() calls. @see #2995393: Refactor migrations plugins that now implement ConfigurablePluginInterface β†’

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ“Œ Task
Status

Postponed

Version

11.0 πŸ”₯

Component
MigrationΒ  β†’

Last updated about 20 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom joachim

Live updates comments and jobs are added and updated live.
  • API clean-up

    Refactors an existing API or subsystem for consistency, performance, modularization, flexibility, third-party integration, etc. May imply an API change. Frequently used during the Code Slush phase of the release cycle.

  • Contributed project blocker

    It denotes an issue that prevents porting of a contributed project to the stable version of Drupal due to missing APIs, regressions, and so on.

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.71.5 2024