Self-reapplying recipes 😈

Created on 22 January 2025, 7 days ago

Problem/Motivation

A need has arisen for recipes to be able to be reapplied automatically under certain conditions. The canonical example is Drupal CMS's SEO Tools recipe -- it attaches a bunch of useful SEO stuff to extant content types, but if you then create a new content type, it won't have any of the SEO things unless you specifically go and reapply the recipe.

Wouldn't it be neat to do that automatically? I think we can do it with ECA, as long as there are a couple of things in place.

Proposed resolution

Here's what we need, in order:

  1. ECA must be able to react when a recipe is applied. An issue for this already exists: ✨ Add support for event RecipeAppliedEvent Active
  2. ECA needs to expose an action plugin that can apply a recipe. It should accept one argument (for now), which is the recipe's Composer package name (e.g. drupal/drupal_cms_seo_tools), and use \Composer\InstalledVersions::getInstallPath() to find out where the recipe is installed. Applying a recipe programmatically is quite easy:
    $recipe = Recipe::createFromDirectory('/path/to/recipe/dir');
    RecipeRunner::processRecipe($recipe);
    

With these two features in place, a recipe could supply (or dynamically create) an ECA model to reapply itself any time a particular condition, or set of conditions, is fulfilled.

✨ Feature request
Status

Active

Version

2.1

Component

Code

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