public function IndexListBuilder::render in Search API 8
Builds the entity listing as renderable array for table.html.twig.
@todo Add a link to add a new item to the #empty text.
Overrides EntityListBuilder::render
File
- src/
IndexListBuilder.php, line 217
Class
- IndexListBuilder
- Builds a listing of search index entities.
Namespace
Drupal\search_apiCode
public function render() {
$entity_groups = $this
->loadGroups();
$list['#type'] = 'container';
$list['#attached']['library'][] = 'search_api/drupal.search_api.admin_css';
$list['servers'] = [
'#type' => 'table',
'#header' => $this
->buildHeader(),
'#rows' => [],
'#empty' => '',
'#attributes' => [
'id' => 'search-api-entity-list',
'class' => [
'search-api-entity-list',
'search-api-entity-list--servers-with-indexes',
],
],
];
foreach ($entity_groups['servers'] as $server_groups) {
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
foreach ($server_groups as $entity) {
$list['servers']['#rows'][$entity
->getEntityTypeId() . '.' . $entity
->id()] = $this
->buildRow($entity);
}
}
// Output the list of indexes without a server separately.
if (!empty($entity_groups['lone_indexes'])) {
$list['lone_indexes']['heading']['#markup'] = '<h3>' . $this
->t('Indexes not currently associated with any server') . '</h3>';
$list['lone_indexes']['table'] = [
'#type' => 'table',
'#header' => $this
->buildHeader(),
'#rows' => [],
'#attributes' => [
'id' => 'search-api-entity-list',
'class' => [
'search-api-entity-list',
'search-api-entity-list--unattached-indexes',
],
],
];
foreach ($entity_groups['lone_indexes'] as $entity) {
$list['lone_indexes']['table']['#rows'][$entity
->id()] = $this
->buildRow($entity);
}
}
elseif (!$list['servers']['#rows']) {
if (static::checkDefaultsModuleCanBeInstalled() === []) {
$list['servers']['#empty'] = $this
->t('There are no servers or indexes defined. For a quick start, we suggest you install the Database Search Defaults module.');
}
else {
$list['servers']['#empty'] = $this
->t('There are no servers or indexes defined.');
}
}
return $list;
}