Problem/Motivation

#3324150: Add validation constraints to config_entity.dependencies added the new ConfigExists constraint. It works well 👍

But it does not support one very common use case: for one config entity to reference another config entity by its ID/name rather than the full config dependency name.

For example:

  1. bundle: article in core/profiles/standard/config/install/core.entity_view_display.node.article.default.yml must be prefixed by node.type. for it to be able to use ConfigExistsConstraint
  2. format: basic_html in core/profiles/demo_umami/config/install/editor.editor.basic_html.yml must be prefixed by filter.format. for it to be able to use ConfigExistsConstraint
  3. field: body in core/profiles/demo_umami/config/install/field.field.node.article.body.yml must be prefixed by field.storage.node for it to be able to use ConfigExistsConstraint
  4. et cetera

Hence this blocks:

Steps to reproduce

N/A

Proposed resolution

  1. Update ConfigExistsConstraint to accept an optional prefix
  2. Update ConfigExistsConstraintValidator to respect the prefix option.
  3. Test coverage, of course

Remaining tasks

User interface changes

None.

API changes

The ConfigExists constraint (added in Drupal 10.1) has a new prefix option which allows it to be used for validating references to a specific config entity. CR: https://www.drupal.org/node/3416240.

Data model changes

None.

Release notes snippet

Issue fork drupal-3422398

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

Wim Leers created an issue. See original summary.

wim leers’s picture

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Active » Needs review

wim leers’s picture

The code I just pushed was previously written for #3412361: Mark Editor config schema as fully validatable. Crediting @phenaproxima for his review of that code.

(This now blocks #3412361: Mark Editor config schema as fully validatable.)

wim leers’s picture

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me!

wim leers’s picture

quietone’s picture

Title: Follow-up for #3324150: allow specifying a prefix for ConfigExistsConstraint, to enable using it for references to config entities » Allow specifying a prefix for ConfigExistsConstraint, to enable using it for references to config entities

Going for a better title. (I don't want to read 'Follow-up for #3324150: ' when I am digging through git history. I can find that out if I need to read this issue)

  • catch committed 8df2251a on 10.3.x
    Issue #3422398 by Wim Leers, phenaproxima: Allow specifying a prefix for...

  • catch committed 7a286515 on 11.x
    Issue #3422398 by Wim Leers, phenaproxima: Allow specifying a prefix for...
catch’s picture

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

Can't find anything to complain about, this looks useful, blocks multiple issues. Committed/pushed to 10.3.x and cherry-picked to 10.2.x, thanks!

wim leers’s picture

socialnicheguru’s picture

Is there a separate commit for Drupal 10.2?

wim leers’s picture

@SocialNicheGuru This did not land in 10.2.

quietone’s picture

@SocialNicheGuru, 10.2.x is in support and receives bug and security fixes.

Status: Fixed » Closed (fixed)

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