You are here

private function ReferenceFinder::loadReferencingEntities in Term reference change 8

Loads all entities with a reference to the given term.

Parameters

\Drupal\taxonomy\TermInterface $term: The term to find references to.

Return value

\Drupal\Core\Entity\EntityInterface[] All entities referencing this term.

1 call to ReferenceFinder::loadReferencingEntities()
ReferenceFinder::findReferencesFor in src/ReferenceFinder.php
Finds and loads all entities with a reference to the given term.

File

src/ReferenceFinder.php, line 69

Class

ReferenceFinder
Finds entities referencing a term.

Namespace

Drupal\term_reference_change

Code

private function loadReferencingEntities(TermInterface $term) {
  $referenceFields = $this
    ->findTermReferenceFields();
  $referencingEntities = [];
  foreach ($referenceFields as $entityType => $bundles) {
    $entitiesOfType = $this
      ->loadReferencingEntitiesOfType($term, $bundles, $entityType);
    if (empty($entitiesOfType)) {
      continue;
    }
    $referencingEntities[$entityType] = $entitiesOfType;
  }
  return $referencingEntities;
}