You are here

private function KmlEncoder::absolutizeUrl in KML 8

Makes sure the url is absolute (appends current host's scheme/host/port if missing).

1 call to KmlEncoder::absolutizeUrl()
KmlEncoder::encode in src/Encoder/KmlEncoder.php
Encodes data into the given format.

File

src/Encoder/KmlEncoder.php, line 143

Class

KmlEncoder
Encodes KML data in XML.

Namespace

Drupal\kml\Encoder

Code

private function absolutizeUrl($url) {
  $components = parse_url($url);
  if (empty($components['scheme'])) {
    $components['scheme'] = \Drupal::request()
      ->getScheme();
  }
  if (empty($components['host'])) {
    $components['host'] = \Drupal::request()
      ->getHost();
  }
  if (empty($components['port']) && \Drupal::request()
    ->getPort() != '80') {
    $components['port'] = \Drupal::request()
      ->getPort();
  }
  return $this
    ->unparse_url($components);
}