Create config action which can create an entity for every bundle of another entity type

Created on 29 July 2024, 2 months ago
Updated 19 September 2024, 9 days ago

Problem/Motivation

The addToAllBundles action supported by fields is very, very useful. But it really would be even better if it worked on all config entity types that target a particular bundle.

For example, if I want to add the same set of meta tags to every content type...there's no way to do that dynamically without Metatag adding a custom config action for it. Simple Sitemap works the same way. Another example is making a content type translatable; you need to add a config entity for each bundle to hold the translation settings.

It's a pretty common pattern, but the recipe system has no real support for it.

Proposed resolution

Create a more generic, derived action called createForAllBundles (and a createIfNotExistsForAllBundles) variant.

As with the existing permissions_per_bundle action, this new action's name will vary based on the entity type being targeted. For example, it will have versions called createForEachNodeType and createIfNotExistsForEachTaxonomyVocabulary.

The syntax will look like this:

config:
  actions:
    metatag.metatag_defaults.node__%bundle:
      createForEachNodeType:
        # Some values here

The %bundle token in the config name will be unconditionally replaced by the bundle ID. That will also happen recursively in whatever values are passed to the action. (This is the same token used by the permissions_per_bundle action.)

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component
recipe systemΒ  β†’

Last updated 1 day ago

Created by

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

Live updates comments and jobs are added and updated live.
  • Starshot blocker

    A potential blocker for Drupal Starshot. More information: http://www.drupal.org/project/starshot

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @phenaproxima
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Starshot is going to need this. Tagging as a blocker.

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts
  • Merge request !8975Proof of concept β†’ (Open) created by phenaproxima
  • Pipeline finished with Failed
    2 months ago
    #237714
  • Pipeline finished with Failed
    2 months ago
    Total: 536s
    #237719
  • Pipeline finished with Success
    2 months ago
    Total: 474s
    #237734
  • Pipeline finished with Success
    2 months ago
    Total: 460s
    #237771
  • Pipeline finished with Success
    2 months ago
    Total: 420s
    #237785
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    Should be 11.x

  • Pipeline finished with Success
    about 1 month ago
    Total: 499s
    #266200
  • πŸ‡©πŸ‡ͺGermany a.dmitriiev

    This is very helpful and needed config action.

    For my use case, the module provides a new form mode that should be added to all node types, as this form mode is used for a new route that the module provides. It has to be added to all bundles.

    With help of config action createForEachNodeType and %bundle placeholder I was able to accomplish this task while testing MR.

    I am not yet changing the status of the issue, but with current state of MR it is possible to create config entities for each bundle of entity type.

    Thank you for a handy feature!

  • Status changed to Needs review 10 days ago
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA
  • Status changed to Active 9 days ago
  • πŸ‡ΊπŸ‡ΈUnited States thejimbirch Cape Cod, Massachusetts

    A little premature for Needs review. I know @phenaproxima wants to work on this more.

Production build 0.71.5 2024