You are here

protected function Cluster::getClientById in Elasticsearch Connector 8

Return the cluster object based on Cluster ID.

Parameters

string $cluster_id:

Return value

\Elasticsearch\Client

File

src/Entity/Cluster.php, line 178
Contains \Drupal\elasticsearch_connector\Entity\Cluster.

Class

Cluster
Defines the search server configuration entity.

Namespace

Drupal\elasticsearch_connector\Entity

Code

protected function getClientById($cluster_id) {
  $client = NULL;
  $default_cluster = self::getDefaultCluster();
  if (!isset($cluster_id) && !empty($default_cluster)) {
    $cluster_id = $default_cluster;
  }
  if (!empty($cluster_id)) {
    $client = FALSE;
    $cluster = self::load($cluster_id);
    if ($cluster) {
      $client = $this
        ->getClientInstance($cluster);
    }
  }
  return $client;
}