You are here

protected function ArrayWidget::buildListItems in Facets 8

Builds a renderable array of result items.

Parameters

\Drupal\facets\FacetInterface $facet: The facet we need to build.

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

Return value

array A renderable array of the result.

Overrides WidgetPluginBase::buildListItems

1 call to ArrayWidget::buildListItems()
ArrayWidget::build in src/Plugin/facets/widget/ArrayWidget.php
Builds the facet widget for rendering.

File

src/Plugin/facets/widget/ArrayWidget.php, line 47

Class

ArrayWidget
A simple widget class that returns a simple array of the facet results.

Namespace

Drupal\facets\Plugin\facets\widget

Code

protected function buildListItems(FacetInterface $facet, ResultInterface $result) {
  if ($children = $result
    ->getChildren()) {
    $items = $this
      ->prepare($result);
    $children_markup = [];
    foreach ($children as $child) {
      $children_markup[] = $this
        ->buildChildren($child);
    }
    $items['children'] = [
      $children_markup,
    ];
  }
  else {
    $items = $this
      ->prepare($result);
  }
  return $items;
}