ComplexDataConstraint.php in Zircon Profile 8.0
File
core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php
View source
<?php
namespace Drupal\Core\Validation\Plugin\Validation\Constraint;
use Symfony\Component\Validator\Constraint;
class ComplexDataConstraint extends Constraint {
public $properties;
public function __construct($options = NULL) {
if (is_array($options) && !array_key_exists('properties', $options)) {
$options = array(
'properties' => $options,
);
}
parent::__construct($options);
$constraint_manager = \Drupal::service('validation.constraint');
foreach ($this->properties as &$constraints) {
foreach ($constraints as $id => $options) {
if (!is_object($options)) {
$constraints[$id] = $constraint_manager
->create($id, $options);
}
}
}
}
public function getDefaultOption() {
return 'properties';
}
public function getRequiredOptions() {
return array(
'properties',
);
}
}