public function ClusterListBuilder::group in Elasticsearch Connector 8.5
Same name and namespace in other branches
- 8.7 src/Controller/ClusterListBuilder.php \Drupal\elasticsearch_connector\Controller\ClusterListBuilder::group()
- 8.2 src/Controller/ClusterListBuilder.php \Drupal\elasticsearch_connector\Controller\ClusterListBuilder::group()
- 8.6 src/Controller/ClusterListBuilder.php \Drupal\elasticsearch_connector\Controller\ClusterListBuilder::group()
Group Elasticsearch indices under their respective clusters.
Return value
array Associative array with the following keys:
- clusters: Array of cluster groups keyed by cluster id. Each item is
itself an array with the cluster and any indices as values.
- lone_indexes: Array of indices without a cluster.
1 call to ClusterListBuilder::group()
- ClusterListBuilder::render in src/
Controller/ ClusterListBuilder.php - Builds the entity listing as renderable array for table.html.twig.
File
- src/
Controller/ ClusterListBuilder.php, line 84
Class
- ClusterListBuilder
- Provides a listing of Clusters along with their indices.
Namespace
Drupal\elasticsearch_connector\ControllerCode
public function group() {
/** @var \Drupal\elasticsearch_connector\Entity\Cluster[] $clusters */
$clusters = $this->storage
->loadMultiple();
/** @var \Drupal\elasticsearch_connector\Entity\Index[] $indices */
$indices = $this->indexStorage
->loadMultiple();
$cluster_groups = [];
$lone_indices = [];
foreach ($clusters as $cluster) {
$cluster_group = [
'cluster.' . $cluster->cluster_id => $cluster,
];
foreach ($indices as $index) {
if ($index->server == $cluster->cluster_id) {
$cluster_group['index.' . $index->index_id] = $index;
}
elseif ($index->server == NULL) {
$lone_indices['index.' . $index->index_id] = $index;
}
}
$cluster_groups['cluster.' . $cluster->cluster_id] = $cluster_group;
}
return [
'clusters' => $cluster_groups,
'lone_indexes' => $lone_indices,
];
}