You are here

public function EntityReferenceIntegrityEntityHandler::getDependentEntityIds in Entity Reference Integrity 8

List the entity IDs that reference the given entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity.

Return value

array Array of entity type IDs with arrays of entity IDs.

Overrides EntityReferenceDependencyManagerInterface::getDependentEntityIds

1 call to EntityReferenceIntegrityEntityHandler::getDependentEntityIds()
EntityReferenceIntegrityEntityHandler::getDependentEntities in src/EntityReferenceIntegrityEntityHandler.php
List the entities that reference the given entity.

File

src/EntityReferenceIntegrityEntityHandler.php, line 75

Class

EntityReferenceIntegrityEntityHandler
Entity reference integrity entity handler.

Namespace

Drupal\entity_reference_integrity

Code

public function getDependentEntityIds(EntityInterface $entity) {
  $referencing_entities = [];
  $referencing_fields = $this->fieldMap
    ->getReferencingFields($entity
    ->getEntityTypeId());
  foreach ($referencing_fields as $source_entity_type_id => $source_fields) {
    $entity_ids = array_values($this
      ->referentialEntityQuery($source_entity_type_id, $source_fields, $entity
      ->id())
      ->execute());
    if (!empty($entity_ids)) {
      $referencing_entities[$source_entity_type_id] = $entity_ids;
    }
  }
  return $referencing_entities;
}