Problem/Motivation

Currently we override ChooseBlockController which is a internal class and that means we cannot make this module stable. Instead we should refactor and preprocess the links with hook_preprocess_links, and hopefully if #3032456: Allow easier altering of Layout Builder block configuration links lands we can make that a bit more simple.

Proposed resolution

  • Do it!

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

johndevman created an issue. See original summary.

johnwebdev’s picture

Assigned: Unassigned » johnwebdev
johnwebdev’s picture

Status: Active » Needs review
FileSize
5.33 KB

This patch uses hook_link_alter() because the Create custom block in the listing is not a #links theme, but a single link.

johnzzon’s picture

Looks good overall!

+++ b/layout_builder_modal.module
@@ -34,3 +34,35 @@ function layout_builder_modal_element_info_alter(array &$types) {
+  if (in_array('use-ajax', $variables['options']['attributes']['class'])) {

Can we maybe flip this if around and return early instead?

if (!in_array('use-ajax', $variables['options']['attributes']['class'])) {
  return;
}

Now we're getting config and building the $data_dialog_options array in all cases even though it potentially might not get used.

johnwebdev’s picture

johnwebdev’s picture

johnzzon’s picture

Status: Needs review » Reviewed & tested by the community

Beautiful!

johnwebdev’s picture

  • johndevman committed 2ee84ac on 8.x-1.x
    Issue #3048169 by johndevman, johnzzon: Refactor to preprocess links...
johnwebdev’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.