Allow recipes to contain an "extra" field with arbitrary information for specific modules to use

Created on 29 January 2025, 24 days ago

Problem/Motivation

Project Browser has a need to expose "follow-up" tasks for recipes; see #3322601-10: Add instructions for configuring installed modules and applied recipes link to config/settings page β†’ .

Core definitely should not have opinions about what kind of information a recipe might need to expose to Project Browser, or any other module that deals with recipe. But it should allow that information to be exposed, if a recipe chooses to. However, the validation of recipe.yml is currently very, very strict and doesn't allow any extra data.

Proposed resolution

Composer solved this problem by supporting an extra field in composer.json. The extra field, if it exists, is generally ignored by Composer; the stuff in it is generally only of interest to specific plugins.

Let's borrow that same concept for recipes. We should allow something like this in recipe.yml:

extra:
  project_browser:
    # Some arbitrary stuff here
  another_module:
    # More other arbitrary stuff here

extra is always optional, but if it is defined, it has only two rules:

  1. It must be an associative array
  2. Its keys need to be valid module names. By "valid", I mean here that they need to follow the form of a valid extension name (i.e., match \Drupal\Core\Extension\ExtensionDiscovery::PHP_FUNCTION_PATTERN). They do not need to be the name of an installed extension, or even an extant one.

As long as extra follows those rules, modules can do whatever they want with it.

The Recipe object will also get a new getExtra($module_name) method. It should not be possible for recipe code to get the full contents of extra; it's internally namespaced to maintain the separation of concerns between different modules' use of their extra data, would might cause APIs to accidentally emerge, which would be A Bad Thing.

✨ Feature request
Status

Active

Version

11.1 πŸ”₯

Component

recipe system

Created by

πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024