Make $consumer optional in Drupal\Core\Plugin\FilteredPluginManagerTrait::getFilteredDefinitions()

Created on 30 May 2024, 3 months ago

Problem/Motivation

In πŸ› Add missing category to Drupal\layout_builder\Plugin\Layout\BlankLayout and let modules and themes alter the list of layouts RTBC , we call Drupal\Core\Plugin\FilteredPluginManagerTrait::getFilteredDefinitions() from Drupal\Core\Layout\LayoutPluginManager::getLayoutOptions(). Since the latter method is in the Core namespace, not a module, there is no meaningful $consumer to pass, but we have to pass something since it is a required parameter.

Proposed resolution

Make $consumer optional.

In these lines, skip the second hook and the optional fourth parameter to alter() if $consumer is not provided:

    $hooks[] = "plugin_filter_{$type}";
    $hooks[] = "plugin_filter_{$type}__{$consumer}";
    $this->moduleHandler()->alter($hooks, $definitions, $extra, $consumer);
    $this->themeManager()->alter($hooks, $definitions, $extra, $consumer);

Remaining tasks

User interface changes

None

API changes

Drupal\Core\Layout\LayoutPluginManager::getLayoutOptions() can be called without providing the $consumer<code> parameter.

Data model changes

None

Release notes snippet

N/A

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
PluginΒ  β†’

Last updated about 14 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024