protected function Collection::initializeNestedConstraints in Plug 7
Initializes the nested constraints.
This method can be overwritten in subclasses to clean up the nested constraints passed to the constructor.
Overrides Composite::initializeNestedConstraints
See also
Collection::initializeNestedConstraints()
File
- lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Constraints/ Collection.php, line 57
Class
- Collection
- @Target({"PROPERTY", "METHOD", "ANNOTATION"})
Namespace
Symfony\Component\Validator\ConstraintsCode
protected function initializeNestedConstraints() {
parent::initializeNestedConstraints();
if (!is_array($this->fields)) {
throw new ConstraintDefinitionException(sprintf('The option "fields" is expected to be an array in constraint %s', __CLASS__));
}
foreach ($this->fields as $fieldName => $field) {
// the XmlFileLoader and YamlFileLoader pass the field Optional
// and Required constraint as an array with exactly one element
if (is_array($field) && count($field) == 1) {
$this->fields[$fieldName] = $field = $field[0];
}
if (!$field instanceof Optional && !$field instanceof Required) {
$this->fields[$fieldName] = $field = new Required($field);
}
}
}