protected function JsonApiResponseWidget::prepare in JSON:API Search API 8
Prepares the URL and values for the facet.
Parameters
\Drupal\facets\Result\ResultInterface $result: A result item.
Return value
array The results.
1 call to JsonApiResponseWidget::prepare()
- JsonApiResponseWidget::buildListItems in modules/
jsonapi_search_api_facets/ src/ Plugin/ facets/ widget/ JsonApiResponseWidget.php - Builds a renderable array of result items.
File
- modules/
jsonapi_search_api_facets/ src/ Plugin/ facets/ widget/ JsonApiResponseWidget.php, line 77
Class
- JsonApiResponseWidget
- A simple widget class that returns for inclusion in JSON:API Search API.
Namespace
Drupal\jsonapi_search_api_facets\Plugin\facets\widgetCode
protected function prepare(ResultInterface $result) {
$values = $this
->generateValues($result);
$url = $result
->getUrl();
if ($url === NULL) {
$facet_values = $values;
}
else {
$facet_values['url'] = $url
->setAbsolute(TRUE)
->toString(TRUE)
->getGeneratedUrl();
$facet_values['values'] = $values;
}
return $facet_values;
}