You are here

public function EntityReferenceFieldItemList::getConstraints in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php \Drupal\Core\Field\EntityReferenceFieldItemList::getConstraints()

Gets a list of validation constraints.

Return value

array Array of constraints, each being an instance of \Symfony\Component\Validator\Constraint.

Overrides FieldItemList::getConstraints

File

core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php, line 21
Contains \Drupal\Core\Field\EntityReferenceFieldItemList.

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;
}