You are here

public function ClusterListBuilder::render in Elasticsearch Connector 8.2

Same name and namespace in other branches
  1. 8.7 src/Controller/ClusterListBuilder.php \Drupal\elasticsearch_connector\Controller\ClusterListBuilder::render()
  2. 8 src/Controller/ClusterListBuilder.php \Drupal\elasticsearch_connector\Controller\ClusterListBuilder::render()
  3. 8.5 src/Controller/ClusterListBuilder.php \Drupal\elasticsearch_connector\Controller\ClusterListBuilder::render()
  4. 8.6 src/Controller/ClusterListBuilder.php \Drupal\elasticsearch_connector\Controller\ClusterListBuilder::render()

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/Controller/ClusterListBuilder.php, line 240
Contains \Drupal\elasticsearch_connector\Controller\ClusterListBuilder.

Class

ClusterListBuilder
Provides a listing of Clusters along with their indices.

Namespace

Drupal\elasticsearch_connector\Controller

Code

public function render() {
  $entity_groups = $this
    ->group();
  $rows = array();
  foreach ($entity_groups['clusters'] as $cluster_group) {
    foreach ($cluster_group as $entity) {
      $rows[$entity
        ->id()] = $this
        ->buildRow($entity);
    }
  }
  $list['#type'] = 'container';
  $list['#attached']['library'][] = 'elasticsearch_connector/drupal.elasticsearch_connector.ec_index';
  $list['clusters'] = array(
    '#type' => 'table',
    '#header' => $this
      ->buildHeader(),
    '#rows' => $rows,
    '#empty' => $this
      ->t('No clusters available. <a href="@link">Add new cluster</a>.', array(
      '@link' => \Drupal::urlGenerator()
        ->generate('entity.elasticsearch_cluster.add_form'),
    )),
  );
  return $list;
}