public function ShowCountProcessor::build in Facets 8
Alter the items in the summary before creating the renderable array.
Parameters
\Drupal\facets_summary\FacetsSummaryInterface $facet: The facet being changed.
array $build: The render array.
\Drupal\facets\FacetInterface[] $facets: The facets that are available.
Return value
array The render array.
Overrides BuildProcessorInterface::build
File
- modules/
facets_summary/ src/ Plugin/ facets_summary/ processor/ ShowCountProcessor.php, line 26
Class
- ShowCountProcessor
- Provides a processor that shows a summary of how many results were found.
Namespace
Drupal\facets_summary\Plugin\facets_summary\processorCode
public function build(FacetsSummaryInterface $facets_summary, array $build, array $facets) {
if (!isset($build['#items'])) {
return $build;
}
$count = $facets_summary
->getFacetSource()
->getCount();
$build_count = [
'#theme' => 'facets_summary_count',
'#count' => $count,
];
array_unshift($build['#items'], $build_count);
return $build;
}