public function RptMapProcessor::build in Search API Location 8
Runs before the renderable array is created.
Parameters
\Drupal\facets\FacetInterface $facet: The facet being changed.
\Drupal\facets\Result\ResultInterface[] $results: The results being changed.
Return value
\Drupal\facets\Result\ResultInterface[] The changed results.
Overrides BuildProcessorInterface::build
File
- modules/
facets_map_widget/ src/ Plugin/ facets/ processor/ RptMapProcessor.php, line 26
Class
- RptMapProcessor
- Provides a processor for faceted map.
Namespace
Drupal\facets_map_widget\Plugin\facets\processorCode
public function build(FacetInterface $facet, array $results) {
/** @var \Drupal\facets\Plugin\facets\processor\UrlProcessorHandler $url_processor_handler */
$url_processor_handler = $facet
->getProcessors()['url_processor_handler'];
$url_processor = $url_processor_handler
->getProcessor();
$filter_key = $url_processor
->getFilterKey();
/** @var \Drupal\facets\Result\ResultInterface[] $results */
foreach ($results as &$result) {
$url = $result
->getUrl();
$query = $url
->getOption('query');
// Remove all the query filters for the field of the facet.
if (isset($query[$filter_key])) {
foreach ($query[$filter_key] as $id => $filter) {
if (strpos($filter . $url_processor
->getSeparator(), $facet
->getUrlAlias()) === 0) {
unset($query[$filter_key][$id]);
}
}
}
$query[$filter_key][] = $facet
->getUrlAlias() . $url_processor
->getSeparator() . '(geom:__GEOM__)';
$url
->setOption('query', $query);
$result
->setUrl($url);
}
return $results;
}