Migration plugins throughout core and contrib keep having to do this sort of thing:
$delimiter = isset($this->configuration['delimiter']) ? $this->configuration['delimiter'] : '';
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.
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 β
None.
None.
None.
Postponed
11.0 π₯
Enhances developer experience.
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.
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.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.