public function TermWeightWidgetOrderProcessor::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/ TermWeightWidgetOrderProcessor.php, line 107
Class
- TermWeightWidgetOrderProcessor
- A processor that orders the term-results by their weight.
Namespace
Drupal\facets\Plugin\facets\processorCode
public function supportsFacet(FacetInterface $facet) {
$data_definition = $facet
->getDataDefinition();
if ($data_definition
->getDataType() === 'entity_reference') {
return TRUE;
}
if (!$data_definition instanceof ComplexDataDefinitionInterface) {
return FALSE;
}
$data_definition = $facet
->getDataDefinition();
$property_definitions = $data_definition
->getPropertyDefinitions();
foreach ($property_definitions as $definition) {
if ($definition instanceof DataReferenceDefinitionInterface && $definition
->getDataType() === 'entity_reference' && $definition
->getConstraint('EntityType') === 'taxonomy_term') {
return TRUE;
}
}
return FALSE;
}