public function SearchApiString::build in Facets 8
Builds the facet information, so it can be rendered.
Overrides QueryTypeInterface::build
File
- src/
Plugin/ facets/ query_type/ SearchApiString.php, line 60
Class
- SearchApiString
- Provides support for string facets within the Search API scope.
Namespace
Drupal\facets\Plugin\facets\query_typeCode
public function build() {
$query_operator = $this->facet
->getQueryOperator();
if (!empty($this->results)) {
$facet_results = [];
foreach ($this->results as $result) {
if ($result['count'] || $query_operator == 'or') {
$result_filter = $result['filter'];
if ($result_filter[0] === '"') {
$result_filter = substr($result_filter, 1);
}
if ($result_filter[strlen($result_filter) - 1] === '"') {
$result_filter = substr($result_filter, 0, -1);
}
$count = $result['count'];
$result = new Result($this->facet, $result_filter, $result_filter, $count);
$facet_results[] = $result;
}
}
$this->facet
->setResults($facet_results);
}
return $this->facet;
}