You are here

public function ReferenceFinder::findTermReferenceFields in Term reference change 8

Finds all term reference fields.

Return value

array Nested array of field names for taxonomy term entity reference fields. [entity type id][bundle id] = array of field names.

Overrides ReferenceFinderInterface::findTermReferenceFields

1 call to ReferenceFinder::findTermReferenceFields()
ReferenceFinder::loadReferencingEntities in src/ReferenceFinder.php
Loads all entities with a reference to the given term.

File

src/ReferenceFinder.php, line 117

Class

ReferenceFinder
Finds entities referencing a term.

Namespace

Drupal\term_reference_change

Code

public function findTermReferenceFields() {
  $termReferenceFields = [];
  $entityTypes = $this->entityTypeManager
    ->getDefinitions();
  foreach ($entityTypes as $entityType) {
    if (!$entityType
      ->entityClassImplements(FieldableEntityInterface::class)) {
      continue;
    }
    $referenceFields = $this
      ->findTermReferenceFieldsForEntityType($entityType
      ->id());
    if (empty($referenceFields)) {
      continue;
    }
    $termReferenceFields[$entityType
      ->id()] = $referenceFields;
  }
  return $termReferenceFields;
}