You are here

public function Cluster::getSafeUrl in Elasticsearch Connector 8.7

Same name and namespace in other branches
  1. 8.2 src/Entity/Cluster.php \Drupal\elasticsearch_connector\Entity\Cluster::getSafeUrl()
  2. 8.5 src/Entity/Cluster.php \Drupal\elasticsearch_connector\Entity\Cluster::getSafeUrl()
  3. 8.6 src/Entity/Cluster.php \Drupal\elasticsearch_connector\Entity\Cluster::getSafeUrl()

Get the full base URL of the cluster, including any authentication.

Return value

string

File

src/Entity/Cluster.php, line 107

Class

Cluster
Defines the Elasticsearch Connector Cluster configuration entity.

Namespace

Drupal\elasticsearch_connector\Entity

Code

public function getSafeUrl() {
  $options = $this->options;
  $url_parsed = parse_url($this->url);
  if ($options['use_authentication']) {
    return $url_parsed['scheme'] . '://' . $options['username'] . ':****@' . $url_parsed['host'] . (isset($url_parsed['port']) ? ':' . $url_parsed['port'] : '');
  }
  else {
    return $url_parsed['scheme'] . '://' . (isset($url_parsed['user']) ? $url_parsed['user'] . ':****@' : '') . $url_parsed['host'] . (isset($url_parsed['port']) ? ':' . $url_parsed['port'] : '');
  }
}