You are here

protected function WidgetPluginBase::buildResultItem in Facets 8

Builds a facet result item.

Parameters

\Drupal\facets\Result\ResultInterface $result: The result item.

Return value

array The facet result item as a render array.

2 calls to WidgetPluginBase::buildResultItem()
WidgetPluginBase::build in src/Widget/WidgetPluginBase.php
Builds the facet widget for rendering.
WidgetPluginBase::prepareLink in src/Widget/WidgetPluginBase.php
Returns the text or link for an item.

File

src/Widget/WidgetPluginBase.php, line 242

Class

WidgetPluginBase
A base class for widgets that implements most of the boilerplate.

Namespace

Drupal\facets\Widget

Code

protected function buildResultItem(ResultInterface $result) {
  $count = $result
    ->getCount();
  return [
    '#theme' => 'facets_result_item',
    '#is_active' => $result
      ->isActive(),
    '#value' => $result
      ->getDisplayValue(),
    '#show_count' => $this
      ->getConfiguration()['show_numbers'] && $count !== NULL,
    '#count' => $count,
    '#facet' => $result
      ->getFacet(),
    '#raw_value' => $result
      ->getRawValue(),
  ];
}