function EntityReferenceFieldItemList::getConstraints

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php \Drupal\Core\Field\EntityReferenceFieldItemList::getConstraints()
  2. 10 core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php \Drupal\Core\Field\EntityReferenceFieldItemList::getConstraints()
  3. 11.x core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php \Drupal\Core\Field\EntityReferenceFieldItemList::getConstraints()

Overrides FieldItemList::getConstraints

File

core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php, line 16

Class

EntityReferenceFieldItemList
Defines a item list class for entity reference fields.

Namespace

Drupal\Core\Field

Code

public function getConstraints() {
    $constraints = parent::getConstraints();
    $constraint_manager = $this->getTypedDataManager()
        ->getValidationConstraintManager();
    $constraints[] = $constraint_manager->create('ValidReference', []);
    return $constraints;
}

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