Derivative plugin definitions contain base plugin IDs instead of derivative IDs

Created on 24 March 2015, about 9 years ago
Updated 30 January 2023, over 1 year ago

Updated as of #70

Problem/Motivation

Most, if not all derivers do not set plugin IDs for derivative definitions explicitly, but provide it by merging in the base plugin definition for defaults. This means that for any derivative definition, the specified ID is that of the base plugin, even though the keys in the definitions array are correct (see #2458723: Incomplete documentation for DiscoveryInterface::getDefinitions() β†’ ).

\Drupal\system\Plugin\Derivative\SystemMenuBlock is a concise example:

  public function getDerivativeDefinitions($base_plugin_definition) {
    foreach ($this->menuStorage->loadMultiple() as $menu => $entity) {
      $this->derivatives[$menu] = $base_plugin_definition;
      $this->derivatives[$menu]['admin_label'] = $entity->label();
      $this->derivatives[$menu]['config_dependencies']['config'] = [$entity->getConfigDependencyName()];
    }
    return $this->derivatives;
  }

In the above example the derivative ID will be $menue main and for derivatives will be of the form $base_plugin_id:$derivative_id system_menu_block:main, but for derivatives, the $definition item contains only the $base_plugin_id system_menu_block, so that multiple $definition values will have the same ID in them.

Proposed resolution

Merge in the derivative ID in \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator.

Remaining tasks

Find a way to set the derivative ID.

User interface changes

None.

API changes

None.

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
PluginΒ  β†’

Last updated about 14 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom Xano Southampton

Live updates comments and jobs are added and updated live.
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.

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

Production build 0.69.0 2024