Problem/Motivation

Recipe input values cannot be used in array keys. For example, something like this won't work:

config:
  actions:
    node.type.${content_type}:
      setLabel: 'Whatever'

In the name of not accidentally creating more API surface, this limitation was deliberate when recipes introduced support for input. I also feared that this would reduce the predictability of recipes by making them behave more like functions. I still think that keeping things tightly scoped and low-key was, at the time, the right call.

But, having had some time to actually implement inputs in certain recipes (for Drupal CMS in particular), I think this is probably more useful than scary. Although it does make the recipe less "predictable" at a glance, it's not that much less predictable -- you can still tell what the recipe will do, it's just a question of what config items it will do it to. They would still not have the ability to make decisions or do branching logic. Recipes would gain the ability to act like content type factories/templates, which is a legitimate use for them.

Proposed resolution

Allow inputs to be replaced in array keys, as well as array values, of config actions. A reasonable limitation, I think, would be to only allow these replacements in the identifying parts of the keys. For example, node.type.${content_type} will work, but ${module}.type.whatever will not, even though node.type and media.type are legitimate config prefixes.

Issue fork drupal-3497061

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

Issue summary: View changes
phenaproxima’s picture

Version: 11.1.x-dev » 11.x-dev
Assigned: Unassigned » phenaproxima

phenaproxima’s picture

Assigned: phenaproxima » Unassigned
Status: Active » Needs review
phenaproxima’s picture

Issue summary: View changes
phenaproxima’s picture

Issue summary: View changes
thejimbirch’s picture

Status: Needs review » Reviewed & tested by the community

Looks good. Moving to RTBC.

phenaproxima’s picture

Tagging for a change record update of https://www.drupal.org/node/3470507, since this will directly obviate its last few paragraphs.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Backported to 11.1.x as recipes are experimental.

Committed and pushed 5db4867689b to 11.x and a2d4afd1622 to 11.1.x. Thanks!

  • alexpott committed a2d4afd1 on 11.1.x
    Issue #3497061 by phenaproxima, alexpott: Allow recipe input values in...

  • alexpott committed 5db48676 on 11.x
    Issue #3497061 by phenaproxima, alexpott: Allow recipe input values in...
phenaproxima’s picture

Change record updated.

Status: Fixed » Closed (fixed)

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