Problem/Motivation

The addComponentToLayout config action is great, but you can only use it once on any given config entity. There's no pluralized version. If you want to add multiple components to a layout you're just screwed.

This is such a knuckleheaded oversight on my part (shoulda noticed this in review) that I am categorizing it as a bug.

Proposed resolution

Add a pluralized version of the action, addComponentsToLayout, for clarity, and change the action to support $value being a list.

Issue fork drupal-3540305

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

phenaproxima created an issue. See original summary.

phenaproxima’s picture

Issue summary: View changes

phenaproxima’s picture

Status: Active » Needs review
thejimbirch’s picture

Status: Needs review » Needs work

PHPstan doesn't like this:

 ------ ---------------------------------------------------------------------- 
  Line   core/modules/layout_builder/src/Plugin/ConfigAction/AddComponent.php  
 ------ ---------------------------------------------------------------------- 
  96     Undefined variable: $value                                            
         🪪 variable.undefined                                                 
 ------ ---------------------------------------------------------------------- 
 [ERROR] Found 1 error    
thejimbirch’s picture

Status: Needs work » Reviewed & tested by the community

Thanks for fixing that. Since it is a bug, it doesn't need a change record. I will add an issue to update our documentation when this lands.

Marking as RTBC.

penyaskito’s picture

@phenaproxima pinged me about this as the author of the original action, this looks great to me.

alexpott’s picture

Version: 11.x-dev » 11.2.x-dev
Status: Reviewed & tested by the community » Fixed

This is a nice improvement. Backported to 11.2.x as recipes and config actions are experimental and this is an addition.

Committed and pushed a8c4e56ccf8 to 11.x and 175d099d3c4 to 11.2.x. Thanks!

  • alexpott committed 175d099d on 11.2.x
    Issue #3540305 by phenaproxima, thejimbirch: The addComponentToLayout...

  • alexpott committed a8c4e56c on 11.x
    Issue #3540305 by phenaproxima, thejimbirch: The addComponentToLayout...

Status: Fixed » Closed (fixed)

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