function ConstraintManager::registerDefinitions

Same name in other branches
  1. 9 core/lib/Drupal/Core/Validation/ConstraintManager.php \Drupal\Core\Validation\ConstraintManager::registerDefinitions()
  2. 8.9.x core/lib/Drupal/Core/Validation/ConstraintManager.php \Drupal\Core\Validation\ConstraintManager::registerDefinitions()
  3. 10 core/lib/Drupal/Core/Validation/ConstraintManager.php \Drupal\Core\Validation\ConstraintManager::registerDefinitions()

Callback for registering definitions for constraints shipped with Symfony.

See also

ConstraintManager::__construct()

File

core/lib/Drupal/Core/Validation/ConstraintManager.php, line 94

Class

ConstraintManager
Constraint plugin manager.

Namespace

Drupal\Core\Validation

Code

public function registerDefinitions() {
    $this->getDiscovery()
        ->setDefinition('Callback', [
        'label' => new TranslatableMarkup('Callback'),
        'class' => Callback::class,
        'type' => FALSE,
    ]);
    $this->getDiscovery()
        ->setDefinition('Blank', [
        'label' => new TranslatableMarkup('Blank'),
        'class' => Blank::class,
        'type' => FALSE,
    ]);
    $this->getDiscovery()
        ->setDefinition('NotBlank', [
        'label' => new TranslatableMarkup('Not blank'),
        'class' => NotBlank::class,
        'type' => FALSE,
    ]);
    $this->getDiscovery()
        ->setDefinition('Email', [
        'label' => new TranslatableMarkup('Email'),
        'class' => EmailConstraint::class,
        'type' => [
            'string',
        ],
    ]);
    $this->getDiscovery()
        ->setDefinition('Choice', [
        'label' => new TranslatableMarkup('Choice'),
        'class' => Choice::class,
        'type' => FALSE,
    ]);
    $this->getDiscovery()
        ->setDefinition('Image', [
        'label' => new TranslatableMarkup('Image'),
        'class' => Image::class,
        'type' => [
            'string',
        ],
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.