protected function ClusterForm::clusterFormInfo in Elasticsearch Connector 8.2
Same name and namespace in other branches
- 8.7 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::clusterFormInfo()
- 8 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::clusterFormInfo()
- 8.5 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::clusterFormInfo()
- 8.6 src/Form/ClusterForm.php \Drupal\elasticsearch_connector\Form\ClusterForm::clusterFormInfo()
Build the cluster info table for the edit page.
Return value
array
1 call to ClusterForm::clusterFormInfo()
- ClusterForm::buildEntityForm in src/
Form/ ClusterForm.php
File
- src/
Form/ ClusterForm.php, line 253 - Contains Drupal\elasticsearch_connector\Form.
Class
- ClusterForm
- Provides a form for the Cluster entity.
Namespace
Drupal\elasticsearch_connector\FormCode
protected function clusterFormInfo() {
$element = array();
if (isset($this->entity->url)) {
try {
$client_connector = $this->clientManager
->getClientForCluster($this->entity);
$cluster_info = $client_connector
->getClusterInfo();
if ($cluster_info) {
$headers = array(
array(
'data' => t('Cluster name'),
),
array(
'data' => t('Status'),
),
array(
'data' => t('Number of nodes'),
),
);
if (isset($cluster_info['state'])) {
$rows = array(
array(
$cluster_info['health']['cluster_name'],
$cluster_info['health']['status'],
$cluster_info['health']['number_of_nodes'],
),
);
$element = array(
'#theme' => 'table',
'#header' => $headers,
'#rows' => $rows,
'#attributes' => array(
'class' => array(
'admin-elasticsearch',
),
'id' => 'cluster-info',
),
);
}
else {
$rows = array(
array(
t('Unknown'),
t('Unavailable'),
'',
),
);
$element = array(
'#theme' => 'table',
'#header' => $headers,
'#rows' => $rows,
'#attributes' => array(
'class' => array(
'admin-elasticsearch',
),
'id' => 'cluster-info',
),
);
}
}
else {
$element['#type'] = 'markup';
$element['#markup'] = '<div id="cluster-info"> </div>';
}
} catch (\Exception $e) {
drupal_set_message($e
->getMessage(), 'error');
}
}
return $element;
}