Add new `EntityBundleExists` constraint

Created on 22 August 2023, about 1 year ago
Updated 14 February 2024, 9 months ago

Problem/Motivation

Over at πŸ“Œ [PP-1] Convert field_storage_config and field_config's form validation logic to validation constraints Postponed , we identified the need for a EntityBundleExists constraint for FieldConfig and BaseFieldOverrideconfig entities.

However, there are at least a few other uses for this:

  1. condition.plugin.entity_bundle:*'s bundles sequence items
  2. views.argument_validator_entity`'s bundles sequence
  3. LanguageContentSettings config entity (language.content_settings.*.*`): target_bundle field
  4. et cetera.

Steps to reproduce

N/A

Proposed resolution

  1. Extract EntityBundleExistsConstraint(Validator from that issue
  2. Add explicit test coverage for the new constraint
  3. Adopt in all config entities in core where it makes sense
  4. adopt in some simple config, if there's little doubt about it being valuable

Remaining tasks

  1. βœ… Constraint + test coverage
  2. βœ… Adopt in all relevant config entities: EntityFormDisplay, EntityViewDisplay, ContentLanguageSettings and FieldConfig
  3. βœ… Update corresponding ConfigEntityValidationTestBase subclasses
  4. βœ… Create change record

User interface changes

None.

API changes

None.

Well, sort of. There's an internal class added, \Drupal\Core\Config\Schema\TypeResolver, which contains logic previously in \Drupal\Core\Config\TypedConfigManager concerned with replacing tokens like %parent with actual, fully resolved config names. TypeResolver exposes that logic as public methods so that the constraint can use it for a little dynamism, since it's very possible that you'll want to sometimes specify entity type IDs using dynamic tokens.

Data model changes

None.

Release notes snippet

None.

πŸ“Œ Task
Status

Fixed

Version

11.0 πŸ”₯

Component
Configuration entityΒ  β†’

Last updated about 1 hour ago

Created by

πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

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