protected function GlossaryAZWidget::buildListItems in Search API AZ Glossary 8
Same name and namespace in other branches
- 8.4 src/Plugin/facets/widget/GlossaryAZWidget.php \Drupal\search_api_glossary\Plugin\facets\widget\GlossaryAZWidget::buildListItems()
- 8.2 src/Plugin/facets/widget/GlossaryAZWidget.php \Drupal\search_api_glossary\Plugin\facets\widget\GlossaryAZWidget::buildListItems()
- 8.3 src/Plugin/facets/widget/GlossaryAZWidget.php \Drupal\search_api_glossary\Plugin\facets\widget\GlossaryAZWidget::buildListItems()
Builds a renderable array of result items.
Parameters
\Drupal\facets\Result\ResultInterface $result: A result item.
Return value
array A renderable array of the result.
Overrides WidgetPluginBase::buildListItems
1 call to GlossaryAZWidget::buildListItems()
- GlossaryAZWidget::build in src/
Plugin/ facets/ widget/ GlossaryAZWidget.php - Builds the facet widget for rendering.
File
- src/
Plugin/ facets/ widget/ GlossaryAZWidget.php, line 70
Class
- GlossaryAZWidget
- The GlossaryAZ widget.
Namespace
Drupal\search_api_glossary\Plugin\facets\widgetCode
protected function buildListItems(ResultInterface $result) {
$classes = [
'facet-item',
'glossaryaz',
];
// Not sure if glossary will have children.
// Removed chilren processing for now.
$items = $this
->prepareLink($result);
if ($result
->isActive()) {
$items['#attributes'] = [
'class' => 'is-active',
];
$classes[] = 'is-active';
}
else {
$items['#attributes'] = [
'class' => 'is-inactive',
];
}
// Add result, no result classes.
if ($result
->getCount() == 0) {
$classes[] = 'no-results';
}
else {
$classes[] = 'yes-results';
}
$items['#wrapper_attributes'] = [
'class' => $classes,
];
return $items;
}