Problem/Motivation
When a composite contraint is initilized in the ContraintManager it 'strips' any configuration you might have.
I'd like to be able to:
AtLeastOneOf:
messageCollection: 'Either block_id and block_revision_id, or block_serialized must be provided.'
constraints:
- ... etc
But currently that is not possible. Initial testing shows the below code works, which could be adapted to the ConstraintManager.
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
$constraint_manager = $container->get('validation.constraint');
$constraints = $configuration['constraints'];
$constraint_instances = [];
foreach ($constraints as $constraint_id => $constraint) {
foreach ($constraint as $constraint_name => $constraint_options) {
$constraint_instances[$constraint_id] = $constraint_manager->create($constraint_name, $constraint_options);
}
}
unset($configuration['constraints']);
return new static($constraint_instances, [SymfonyConstraint::DEFAULT_GROUP], ...$configuration);
}
Steps to reproduce
Proposed resolution
Ajust the ConstraintManager to allow for options to be passed. Needs proper testing though.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Comments
Comment #2
bbralaComment #3
bbralaParent is merged, so we can move on with this.
Comment #4
bbralaThis might be outdated. #3535734: Make block.settings.inline_block:* fully validatable does set collectionMessage on a collection constrant...