W3cubDocs

/Drupal 8

public function ConstraintManager::getDefinitionsByType

public ConstraintManager::getDefinitionsByType($type)

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 130

Class

ConstraintManager
Constraint plugin manager.

Namespace

Drupal\Core\Validation

Code

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Validation!ConstraintManager.php/function/ConstraintManager::getDefinitionsByType/8.1.x