diff --git a/src/Plugin/facets/processor/TranslateEntityProcessor.php b/src/Plugin/facets/processor/TranslateEntityProcessor.php index 0b3c982..657ac4a 100644 --- a/src/Plugin/facets/processor/TranslateEntityProcessor.php +++ b/src/Plugin/facets/processor/TranslateEntityProcessor.php @@ -126,21 +126,8 @@ class TranslateEntityProcessor extends ProcessorPluginBase implements BuildProce $entity = $entity->getTranslation($language_interface->getId()); } - // Find the correct label based on the type of entity. - switch ($entity_type) { - case 'taxonomy_term': - $label = $entity->getName(); - break; - case 'node': - $label = $entity->getTitle(); - break; - default: - $label = $entity->label(); - break; - } - // Overwrite the result's display value. - $results[$i]->setDisplayValue($label); + $results[$i]->setDisplayValue($entity->label()); } // Return the results with the new display values. diff --git a/tests/src/Unit/Plugin/processor/TranslateEntityProcessorTest.php b/tests/src/Unit/Plugin/processor/TranslateEntityProcessorTest.php index c4dfc73..05a6e05 100644 --- a/tests/src/Unit/Plugin/processor/TranslateEntityProcessorTest.php +++ b/tests/src/Unit/Plugin/processor/TranslateEntityProcessorTest.php @@ -131,7 +131,7 @@ class TranslateEntityProcessorTest extends UnitTestCase { ->disableOriginalConstructor() ->getMock(); $node->expects($this->any()) - ->method('getTitle') + ->method('label') ->willReturn('shaken not stirred'); $nodes = [ 2 => $node, @@ -195,7 +195,7 @@ class TranslateEntityProcessorTest extends UnitTestCase { ->disableOriginalConstructor() ->getMock(); $term->expects($this->once()) - ->method('getName') + ->method('label') ->willReturn('Burrowing owl'); $terms = [ 1 => $term,