Use hook_plugin_filter_TYPE_alter instead of hook_layout_alter?

Created on 1 November 2023, about 1 year ago

Problem/Motivation

Currently we use hook_layout_alter() in the module file. This doesn't seem wrong, as its API docs example exactly does the same thing we do here:

function hook_layout_alter(&$definitions) {

  // Remove a layout.
  unset($definitions['twocol']);
}

https://api.drupal.org/api/drupal/core%21core.api.php/function/hook_layo...

but we might also use hook_plugin_filter_TYPE_alter() like layout_builder.module does:

/**
 * Implements hook_plugin_filter_TYPE_alter().
 */
function layout_builder_plugin_filter_layout_alter(array &$definitions, array $extra, $consumer) {
  // Hide the blank layout plugin from listings.
  unset($definitions['layout_builder_blank']);
}

and I'm not really sure what's better or correct.

So this issue is just a note and should not be implemented, until there are clear benefits! Changing this might also break things! I saw that other hook when working on πŸ› Add missing category to Drupal\layout_builder\Plugin\Layout\BlankLayout and let modules and themes alter the list of layouts Fixed

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Postponed

Version

2.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

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

Comments & Activities

Production build 0.71.5 2024