public function RangeSliderProcessor::preQuery in Facets 8
Runs before the query is executed.
Uses the queryType and the facetSource implementation to make sure the alteration to the query was added before the query is executed in the backend?
Parameters
\Drupal\facets\FacetInterface $facet: The facet being changed.
Overrides PreQueryProcessorInterface::preQuery
File
- modules/
facets_range_widget/ src/ Plugin/ facets/ processor/ RangeSliderProcessor.php, line 28
Class
- RangeSliderProcessor
- Provides a processor that adds all range values between an min and max range.
Namespace
Drupal\facets_range_widget\Plugin\facets\processorCode
public function preQuery(FacetInterface $facet) {
$active_items = $facet
->getActiveItems();
array_walk($active_items, function (&$item) {
if (preg_match('/\\(min:((?:-)?[\\d\\.]+),max:((?:-)?[\\d\\.]+)\\)/i', $item, $matches)) {
$item = [
$matches[1],
$matches[2],
];
}
else {
$item = NULL;
}
});
$facet
->setActiveItems($active_items);
}