From a3940d6ee9a05de00e2ada9acaff48ce5542e7c5 Mon Sep 17 00:00:00 2001 From: Jonathan Hedstrom Date: Mon, 20 Nov 2017 10:42:21 -0800 Subject: [PATCH] Merge pull request #117 from Sut3kh/fix-d8-user-entity-ref-field Fix d8 User Entity Reference fields Signed-off-by: Jonathan Hedstrom --- .../Driver/Fields/Drupal8/EntityReferenceHandler.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Drupal/Driver/Fields/Drupal8/EntityReferenceHandler.php b/src/Drupal/Driver/Fields/Drupal8/EntityReferenceHandler.php index 0552b6fe..e2c8fc3f 100644 --- a/src/Drupal/Driver/Fields/Drupal8/EntityReferenceHandler.php +++ b/src/Drupal/Driver/Fields/Drupal8/EntityReferenceHandler.php @@ -14,7 +14,15 @@ public function expand($values) { $return = array(); $entity_type_id = $this->fieldInfo->getSetting('target_type'); $entity_definition = \Drupal::entityManager()->getDefinition($entity_type_id); - $label_key = $entity_definition->getKey('label'); + + // Determine label field key. + if ($entity_type_id !== 'user') { + $label_key = $entity_definition->getKey('label'); + } + else { + // Entity Definition->getKey('label') returns false for users. + $label_key = 'name'; + } // Determine target bundle restrictions. $target_bundle_key = NULL;