You are here

public function ClusterListBuilder::render in Elasticsearch Connector 8

Same name and namespace in other branches
  1. 8.7 src/Controller/ClusterListBuilder.php \Drupal\elasticsearch_connector\Controller\ClusterListBuilder::render()
  2. 8.2 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 182
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
    ->load();
  $list['#type'] = 'container';
  $list['clusters'] = array(
    '#type' => 'table',
    '#header' => $this
      ->buildHeader(),
    '#rows' => array(),
    '#empty' => $this
      ->t('No clusters available. <a href="@link">Add new cluster</a>.', array(
      '@link' => \Drupal::urlGenerator()
        ->generate('entity.elasticsearch_cluster.add_form'),
    )),
  );
  foreach ($entity_groups as $cluster_group) {
    foreach ($cluster_group as $entity) {
      $list['clusters']['#rows'][$entity
        ->id()] = $this
        ->buildRow($entity);
    }
  }
  return $list;
}