You are here

public function SearchApiRpt::build in Search API Location 8

Builds the facet information, so it can be rendered.

Overrides QueryTypeInterface::build

File

modules/facets_map_widget/src/Plugin/facets/query_type/SearchApiRpt.php, line 62

Class

SearchApiRpt
Provides support for location facets within the Search API scope.

Namespace

Drupal\facets_map_widget\Plugin\facets\query_type

Code

public function build() {
  $query_operator = $this->facet
    ->getQueryOperator();
  if (empty($this->results)) {
    return $this->facet;
  }
  $facet_results = [];
  foreach ($this->results as $key => $result) {
    if ($result['count'] || $query_operator == 'or') {
      $count = $result['count'];
      $result = new Result($this->facet, $result['filter'], "heatmap", $count);
      $facet_results[] = $result;
    }
  }
  $this->facet
    ->setResults($facet_results);
  return $this->facet;
}