function DefaultSelection::validateReferenceableEntities

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php \Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection::validateReferenceableEntities()
  2. 8.9.x core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php \Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection::validateReferenceableEntities()
  3. 11.x core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php \Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection::validateReferenceableEntities()

Overrides SelectionInterface::validateReferenceableEntities

1 method overrides DefaultSelection::validateReferenceableEntities()
CommentSelection::validateReferenceableEntities in core/modules/comment/src/Plugin/EntityReferenceSelection/CommentSelection.php
Validates which existing entities can be referenced.

File

core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php, line 383

Class

DefaultSelection
Default plugin implementation of the Entity Reference Selection plugin.

Namespace

Drupal\Core\Entity\Plugin\EntityReferenceSelection

Code

public function validateReferenceableEntities(array $ids) {
    $result = [];
    if ($ids) {
        $target_type = $this->configuration['target_type'];
        $entity_type = $this->entityTypeManager
            ->getDefinition($target_type);
        $query = $this->buildEntityQuery();
        $result = $query->condition($entity_type->getKey('id'), $ids, 'IN')
            ->execute();
    }
    return $result;
}

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