private function SearchApiAlgoliaBackend::extractFacetsData in Search API Algolia 2.0.x
Same name and namespace in other branches
- 8 src/Plugin/search_api/backend/SearchApiAlgoliaBackend.php \Drupal\search_api_algolia\Plugin\search_api\backend\SearchApiAlgoliaBackend::extractFacetsData()
- 3.0.x src/Plugin/search_api/backend/SearchApiAlgoliaBackend.php \Drupal\search_api_algolia\Plugin\search_api\backend\SearchApiAlgoliaBackend::extractFacetsData()
Extract facets data from response.
Parameters
array $facets: Facets to extract.
array $data: Facets data from response.
Return value
array Facets data in format required by Drupal.
1 call to SearchApiAlgoliaBackend::extractFacetsData()
- SearchApiAlgoliaBackend::search in src/
Plugin/ search_api/ backend/ SearchApiAlgoliaBackend.php
File
- src/
Plugin/ search_api/ backend/ SearchApiAlgoliaBackend.php, line 704
Class
- SearchApiAlgoliaBackend
- Class SearchApiAlgoliaBackend.
Namespace
Drupal\search_api_algolia\Plugin\search_api\backendCode
private function extractFacetsData(array $facets, array $data) {
$facets_data = [];
foreach ($data as $field => $facet_data) {
if (!in_array($field, $facets)) {
continue;
}
foreach ($facet_data as $value => $count) {
$facets_data[$field][] = [
'count' => $count,
'filter' => '"' . $value . '"',
];
}
}
return $facets_data;
}