Problem/Motivation

Project Browser has a need to expose "follow-up" tasks for recipes; see #3322601-10: Make ModuleActivator expose a Configure follow-up task for modules which have one.

Core definitely should not have opinions about what kind of information a recipe might choose to expose to Project Browser, or any other module. 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 property in composer.json. The extra property, if it exists, is generally ignored by Composer; the stuff in it is usually only of interest to specific plugins and add-ons.

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, the recipe can have anything it wants in there.

The Recipe object will also get a new getExtra($module_name) method. It will not be possible to get the full contents of extra; it's internally namespaced to maintain the separation between different modules' use of extra data, and to prevent discourage accidental APIs from emerging.

Issue fork drupal-3503190

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

Issue summary: View changes
thejimbirch’s picture

Issue tags: +Recipes initiative

phenaproxima’s picture

Issue summary: View changes
quietone’s picture

Version: 11.1.x-dev » 11.x-dev
phenaproxima’s picture

Status: Active » Needs review
thejimbirch’s picture

The code in the MR looks good and the tests make sense.

My only concern is "extra" field. Since fields are things already in Drupal, and we have a heavy lift educating folks around recipes, could we user "properties"? I don't want to bike shed or anything, just trying to lower the confusion.

thejimbirch’s picture

I hit save too soon. Properties are what composer.json uses

https://getcomposer.org/doc/04-schema.md#properties

phenaproxima’s picture

Title: Allow recipes to contain an "extra" field with arbitrary information for specific modules to use » Allow recipes to contain an "extra" property with arbitrary information for specific modules to use
Issue summary: View changes
thejimbirch’s picture

Status: Needs review » Reviewed & tested by the community
phenaproxima’s picture

Issue summary: View changes
alexpott’s picture

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

Committed and pushed c92120799c4 to 11.x and b436c8c9c47 to 11.1.x. Thanks!

Backported to 11.1.x as it is pure addition, recipes is still experimental and helps unblock features for Drupal CMS.

  • alexpott committed b436c8c9 on 11.1.x
    Issue #3503190 by phenaproxima, thejimbirch: Allow recipes to contain an...

  • alexpott committed c9212079 on 11.x
    Issue #3503190 by phenaproxima, thejimbirch: Allow recipes to contain an...

Status: Fixed » Closed (fixed)

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