function ConstraintManager::getDefinitionsByType

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

Returns a list of constraints that support the given type.

Parameters

string $type: The type to filter on.

Return value

array An array of constraint plugin definitions supporting the given type, keyed by constraint name (plugin ID).

File

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

Class

ConstraintManager
Constraint plugin manager.

Namespace

Drupal\Core\Validation

Code

public function getDefinitionsByType($type) {
    $definitions = [];
    foreach ($this->getDefinitions() as $plugin_id => $definition) {
        if ($definition['type'] === FALSE || in_array($type, $definition['type'])) {
            $definitions[$plugin_id] = $definition;
        }
    }
    return $definitions;
}

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