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
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:
- 3497061-allow-recipe-input
changes, plain diff MR !10815
Comments
Comment #2
phenaproximaComment #3
phenaproximaComment #4
phenaproximaComment #6
phenaproximaComment #7
phenaproximaComment #8
phenaproximaComment #9
thejimbirch commentedLooks good. Moving to RTBC.
Comment #10
phenaproximaTagging for a change record update of https://www.drupal.org/node/3470507, since this will directly obviate its last few paragraphs.
Comment #11
alexpottBackported to 11.1.x as recipes are experimental.
Committed and pushed 5db4867689b to 11.x and a2d4afd1622 to 11.1.x. Thanks!
Comment #14
phenaproximaChange record updated.