You are here

protected function EntityReference::getReferenceableEntities in Views Entity Reference Filter 8

Gets the entities that can be filtered by.

Return value

\Drupal\Core\Entity\EntityInterface[]

1 call to EntityReference::getReferenceableEntities()
EntityReference::getValueOptions in src/Plugin/views/filter/EntityReference.php
Child classes should be used to override this function and set the 'value options', unless 'options callback' is defined as a valid function or static public method to generate these values.

File

src/Plugin/views/filter/EntityReference.php, line 185

Class

EntityReference
Provides a Views filter for entity reference fields.

Namespace

Drupal\verf\Plugin\views\filter

Code

protected function getReferenceableEntities() {
  if ($this->referenceableEntities !== NULL) {
    return $this->referenceableEntities;
  }
  $target_ids = NULL;

  // Filter by bundle if if the plugin was configured to do so.
  $target_bundles = array_filter($this->options['verf_target_bundles']);
  if ($this->targetEntityType
    ->hasKey('bundle') && $target_bundles) {
    $query = $this->targetEntityStorage
      ->getQuery();
    $query
      ->condition($this->targetEntityType
      ->getKey('bundle'), $target_bundles, 'IN');
    $target_ids = $query
      ->execute();
  }
  $this->referenceableEntities = $this->targetEntityStorage
    ->loadMultiple($target_ids);
  return $this->referenceableEntities;
}