diff --git a/src/Plugin/facets/processor/TranslateEntityProcessor.php b/src/Plugin/facets/processor/TranslateEntityProcessor.php index 8b3b70c..e13cd2f 100644 --- a/src/Plugin/facets/processor/TranslateEntityProcessor.php +++ b/src/Plugin/facets/processor/TranslateEntityProcessor.php @@ -5,6 +5,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\Core\TypedData\DataReferenceDefinition; use Drupal\Core\TypedData\TranslatableInterface; use Drupal\facets\Exception\InvalidProcessorException; use Drupal\facets\FacetInterface; @@ -84,12 +85,20 @@ public function build(FacetInterface $facet, array $results) { /** @var \Drupal\Core\TypedData\DataDefinitionInterface $field_definition */ $field_definition = $facet->getFacetSource() ->getDataDefinition($facet->getFieldIdentifier()); - if ($field_definition->getPropertyDefinition('entity') === NULL) { + + $property = NULL; + foreach ($field_definition->getPropertyDefinitions() as $k => $definition) { + if ($definition instanceof DataReferenceDefinition && $definition->getDataType() === 'entity_reference') { + $property = $k; + } + } + + if ($property === NULL) { throw new InvalidProcessorException("Field doesn't have an entity definition, so this processor doesn't work."); } $entity_type = $field_definition - ->getPropertyDefinition('entity') + ->getPropertyDefinition($property) ->getTargetDefinition() ->getEntityTypeId();