You are here

function akamai_tokens in Akamai 8.3

Implements hook_tokens().

File

./akamai.module, line 36
Hook implementations for the Akamai Drupal 8 integration module.

Code

function akamai_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
  $replacements = [];
  if ($type == 'akamai') {
    if ($edgescapeTokens = \Drupal::token()
      ->findWithPrefix($tokens, 'edgescape')) {
      $edgescape = \Drupal::service('akamai.helper.edgescape');
      foreach ($edgescapeTokens as $type => $original) {
        $replacements[$original] = $edgescape
          ->getInformationByType($type);
      }
    }
  }
  return $replacements;
}