You are here

protected function WidgetValidationBase::validateDataDefinition in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/WidgetValidationBase.php \Drupal\entity_browser\WidgetValidationBase::validateDataDefinition()

Creates and validates instances of typed data for each Entity.

Parameters

\Drupal\Core\TypedData\DataDefinitionInterface $data_definition: The data definition generated from ::getDataDefinition().

array $entities: An array of Entities to validate the definition against.

Return value

\Symfony\Component\Validator\ConstraintViolationListInterface A list of violations.

1 call to WidgetValidationBase::validateDataDefinition()
WidgetValidationBase::validate in src/WidgetValidationBase.php
Validates the widget.

File

src/WidgetValidationBase.php, line 130

Class

WidgetValidationBase
Base implementation for widget validation plugins.

Namespace

Drupal\entity_browser

Code

protected function validateDataDefinition(DataDefinitionInterface $data_definition, array $entities) {
  $violations = new ConstraintViolationList();
  foreach ($entities as $entity) {
    $validation_result = $this->typedDataManager
      ->create($data_definition, $entity)
      ->validate();
    $violations
      ->addAll($validation_result);
  }
  return $violations;
}