Collection.php in Zircon Profile 8.0
File
vendor/symfony/validator/Constraints/Collection.php
View source
<?php
namespace Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
class Collection extends Composite {
const MISSING_FIELD_ERROR = 1;
const NO_SUCH_FIELD_ERROR = 2;
protected static $errorNames = array(
self::MISSING_FIELD_ERROR => 'MISSING_FIELD_ERROR',
self::NO_SUCH_FIELD_ERROR => 'NO_SUCH_FIELD_ERROR',
);
public $fields = array();
public $allowExtraFields = false;
public $allowMissingFields = false;
public $extraFieldsMessage = 'This field was not expected.';
public $missingFieldsMessage = 'This field is missing.';
public function __construct($options = null) {
if (is_array($options) && !array_intersect(array_keys($options), array(
'groups',
'fields',
'allowExtraFields',
'allowMissingFields',
'extraFieldsMessage',
'missingFieldsMessage',
))) {
$options = array(
'fields' => $options,
);
}
parent::__construct($options);
}
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) {
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);
}
}
}
public function getRequiredOptions() {
return array(
'fields',
);
}
protected function getCompositeOption() {
return 'fields';
}
}
Classes
Name |
Description |
Collection |
@Target({"PROPERTY", "METHOD", "ANNOTATION"}) |