You are here

public function Edgescape::getInformationByType in Akamai 8.3

Get Edgecape information by type.

Parameters

string $type: An Edgescape location information type identifier string.

Return value

string A string containing Edgescape location information, if available.

File

src/Helper/Edgescape.php, line 59

Class

Edgescape
Provides help for working with Akamai Edgescape.

Namespace

Drupal\akamai\Helper

Code

public function getInformationByType($type) {
  $info = self::EMPTY_STRING;
  $enabled = $this->configFactory
    ->get(self::AKAMAI_SETTINGS)
    ->get(self::EDGESCAPE_SUPPORT);
  if ($enabled && ($header = $this->request->headers
    ->get(self::EDGESCAPE_HEADER, self::EMPTY_STRING))) {
    $header = strtr($header, self::EDGESCAPE_SEPARATOR, self::ARG_SEPARATOR);
    $header_values = [];
    parse_str($header, $header_values);
    if (array_key_exists($type, $header_values)) {
      $info = Html::escape($header_values[(string) $type]);
    }
  }
  return $info;
}