You are here

public function TranslateEntityProcessor::supportsFacet in Facets 8

Checks if the facet is supported by this widget.

Reasons why this would be unsupported can be chosen by the widget.

Parameters

\Drupal\facets\FacetInterface $facet: The facet to check for.

Return value

bool Returns true when allowed, false otherwise.

Overrides ProcessorPluginBase::supportsFacet

See also

\Drupal\facets\Widget\WidgetPluginInterface::supportsFacet

File

src/Plugin/facets/processor/TranslateEntityProcessor.php, line 143

Class

TranslateEntityProcessor
Transforms the results to show the translated entity label.

Namespace

Drupal\facets\Plugin\facets\processor

Code

public function supportsFacet(FacetInterface $facet) {
  $data_definition = $facet
    ->getDataDefinition();
  if ($data_definition
    ->getDataType() === 'entity_reference') {
    return TRUE;
  }
  if (!$data_definition instanceof ComplexDataDefinitionInterface) {
    return FALSE;
  }
  $property_definitions = $data_definition
    ->getPropertyDefinitions();
  foreach ($property_definitions as $definition) {
    if ($definition instanceof DataReferenceDefinitionInterface) {
      return TRUE;
    }
  }
  return FALSE;
}