Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Collection.php

function Collection::__construct

Same name in this branch
  1. 11.1.x vendor/ramsey/collection/src/Collection.php \Ramsey\Collection\Collection::__construct()
  2. 11.1.x vendor/phpdocumentor/type-resolver/src/Types/Collection.php \phpDocumentor\Reflection\Types\Collection::__construct()

Parameters

array<string,Constraint>|array<string,mixed>|null $fields An associative array defining keys in the collection and their constraints:

string[]|null $groups:

bool|null $allowExtraFields Whether to allow additional keys not declared in the configured fields (defaults to false):

bool|null $allowMissingFields Whether to allow the collection to lack some fields declared in the configured fields (defaults to false):

Overrides Composite::__construct

File

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

Class

Collection
Validates a collection with constraints defined for specific keys.

Namespace

Symfony\Component\Validator\Constraints

Code

public function __construct(mixed $fields = null, ?array $groups = null, mixed $payload = null, ?bool $allowExtraFields = null, ?bool $allowMissingFields = null, ?string $extraFieldsMessage = null, ?string $missingFieldsMessage = null) {
    if (self::isFieldsOption($fields)) {
        $fields = [
            'fields' => $fields,
        ];
    }
    parent::__construct($fields, $groups, $payload);
    $this->allowExtraFields = $allowExtraFields ?? $this->allowExtraFields;
    $this->allowMissingFields = $allowMissingFields ?? $this->allowMissingFields;
    $this->extraFieldsMessage = $extraFieldsMessage ?? $this->extraFieldsMessage;
    $this->missingFieldsMessage = $missingFieldsMessage ?? $this->missingFieldsMessage;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal