You are here

class Collection in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/symfony/validator/Constraints/Collection.php \Symfony\Component\Validator\Constraints\Collection
  2. 8.0 vendor/zendframework/zend-feed/src/Reader/Collection.php \Zend\Feed\Reader\Collection
  3. 8.0 vendor/zendframework/zend-feed/src/Reader/Collection/Collection.php \Zend\Feed\Reader\Collection\Collection
  4. 8.0 vendor/phpdocumentor/reflection-docblock/src/phpDocumentor/Reflection/DocBlock/Type/Collection.php \phpDocumentor\Reflection\DocBlock\Type\Collection
Same name and namespace in other branches
  1. 8 vendor/symfony/validator/Constraints/Collection.php \Symfony\Component\Validator\Constraints\Collection

@Target({"PROPERTY", "METHOD", "ANNOTATION"})

@author Bernhard Schussek <bschussek@gmail.com>

Hierarchy

  • class \Symfony\Component\Validator\Constraint
    • class \Symfony\Component\Validator\Constraints\Composite
      • class \Symfony\Component\Validator\Constraints\Collection

Expanded class hierarchy of Collection

Related topics

6 files declare their use of Collection
AnnotationLoaderTest.php in vendor/symfony/validator/Tests/Mapping/Loader/AnnotationLoaderTest.php
CollectionTest.php in vendor/symfony/validator/Tests/Constraints/CollectionTest.php
CollectionValidatorTest.php in vendor/symfony/validator/Tests/Constraints/CollectionValidatorTest.php
LegacyExecutionContextTest.php in vendor/symfony/validator/Tests/LegacyExecutionContextTest.php
XmlFileLoaderTest.php in vendor/symfony/validator/Tests/Mapping/Loader/XmlFileLoaderTest.php

... See full list

2 string references to 'Collection'
config_collection_install_test.schema.yml in core/modules/config/tests/config_collection_install_test/config/schema/config_collection_install_test.schema.yml
core/modules/config/tests/config_collection_install_test/config/schema/config_collection_install_test.schema.yml
EasyRdf_Parser_RdfXml::startState2 in vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/RdfXml.php
@ignore

File

vendor/symfony/validator/Constraints/Collection.php, line 22

Namespace

Symfony\Component\Validator\Constraints
View source
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.';

  /**
   * {@inheritdoc}
   */
  public function __construct($options = null) {

    // no known options set? $options is the fields array
    if (is_array($options) && !array_intersect(array_keys($options), array(
      'groups',
      'fields',
      'allowExtraFields',
      'allowMissingFields',
      'extraFieldsMessage',
      'missingFieldsMessage',
    ))) {
      $options = array(
        'fields' => $options,
      );
    }
    parent::__construct($options);
  }

  /**
   * {@inheritdoc}
   */
  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);
      }
    }
  }
  public function getRequiredOptions() {
    return array(
      'fields',
    );
  }
  protected function getCompositeOption() {
    return 'fields';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Collection::$allowExtraFields public property
Collection::$allowMissingFields public property
Collection::$errorNames protected static property Maps error codes to the names of their constants. Overrides Constraint::$errorNames
Collection::$extraFieldsMessage public property
Collection::$fields public property
Collection::$missingFieldsMessage public property
Collection::getCompositeOption protected function Returns the name of the property that contains the nested constraints. Overrides Composite::getCompositeOption
Collection::getRequiredOptions public function Returns the name of the required options. Overrides Constraint::getRequiredOptions
Collection::initializeNestedConstraints protected function Initializes the nested constraints. Overrides Composite::initializeNestedConstraints
Collection::MISSING_FIELD_ERROR constant
Collection::NO_SUCH_FIELD_ERROR constant
Collection::__construct public function The groups of the composite and its nested constraints are made consistent using the following strategy: Overrides Composite::__construct
Composite::addImplicitGroupName public function Implicit group names are forwarded to nested constraints. Overrides Constraint::addImplicitGroupName
Constraint::$payload public property Domain-specific data attached to a constraint.
Constraint::CLASS_CONSTRAINT constant Marks a constraint that can be put onto classes.
Constraint::DEFAULT_GROUP constant The name of the group given to all constraints with no explicit group.
Constraint::getDefaultOption public function Returns the name of the default option. 18
Constraint::getErrorName public static function Returns the name of the given error code.
Constraint::getTargets public function Returns whether the constraint can be put onto classes, properties or both. 11
Constraint::PROPERTY_CONSTRAINT constant Marks a constraint that can be put onto properties.
Constraint::validatedBy public function Returns the name of the class that validates this constraint. 11
Constraint::__get public function Returns the value of a lazily initialized option. 1
Constraint::__set public function Sets the value of a lazily initialized option. 1
Constraint::__sleep public function Optimizes the serialized value to minimize storage space.