diff --git a/src/Drupal/Driver/Fields/Drupal8/EntityReferenceHandler.php b/src/Drupal/Driver/Fields/Drupal8/EntityReferenceHandler.php index 5d3df71..5ea3217 100644 --- a/src/Drupal/Driver/Fields/Drupal8/EntityReferenceHandler.php +++ b/src/Drupal/Driver/Fields/Drupal8/EntityReferenceHandler.php @@ -15,6 +15,8 @@ public function expand($values) { $entity_type_id = $this->fieldInfo->getSetting('target_type'); $entity_definition = \Drupal::entityTypeManager()->getDefinition($entity_type_id); + $id_key = $entity_definition->getKey('id'); + // Determine label field key. if ($entity_type_id !== 'user') { $label_key = $entity_definition->getKey('label'); @@ -35,7 +37,11 @@ public function expand($values) { } foreach ((array) $values as $value) { - $query = \Drupal::entityQuery($entity_type_id)->condition($label_key, $value); + $query = \Drupal::entityQuery($entity_type_id); + $or = $query->orConditionGroup(); + $or->condition($id_key, $value) + ->condition($label_key, $value); + $query->condition($or); $query->accessCheck(FALSE); if ($target_bundles && $target_bundle_key) { $query->condition($target_bundle_key, $target_bundles, 'IN');