Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292386

ComponentValidator ignores the set validator and creates a new one

$
0
0

Problem/Motivation

\Drupal\Core\Theme\Component\ComponentValidator has a method to setValidator
This allows contrib modules to change how the component validator behaves, including things like

  • Add their own constraints (JSON Schema constraints, not Symfony validation constraints! So: \JsonSchema\Constraints\ConstraintInterface implementations, not \Symfony\Component\Validator\Constraint subclasses)
  • Changing the constraint factory (again: JSON Schema constraints!)

These however are ignored by ::validateProps as it calls $validator = new Validator() instead of using the set validator

Steps to reproduce

Try to override the constraint factory by doing something like this:

$component_validator = new ComponentValidator();
    $component_validator->setValidator(new Validator((new Factory())->setConstraintClass('format', UrlHelperFormatConstraint::class)));

where UrlHelperFormatConstraint is a custom constraint.

Proposed resolution

Use the existing validator after resetting it

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 292386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>