You are here

akamai.module in Akamai 8.3

Hook implementations for the Akamai Drupal 8 integration module.

File

akamai.module
View source
<?php

/**
 * @file
 * Hook implementations for the Akamai Drupal 8 integration module.
 */
use Drupal\Core\Render\BubbleableMetadata;

/**
 * Implements hook_token_info().
 */
function akamai_token_info() {
  return [
    'types' => [
      'akamai' => [
        'name' => t('Akamai'),
        'description' => t('Tokens providing access to Akamai-related information.'),
      ],
    ],
    'tokens' => [
      'akamai' => [
        'edgescape' => [
          'name' => t('Edgescape'),
          'description' => t('The type of Edgescape location information, for instance <code>continent</code> or <code>country_code</code>.'),
          'dynamic' => TRUE,
        ],
      ],
    ],
  ];
}

/**
 * Implements hook_tokens().
 */
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;
}

Functions

Namesort descending Description
akamai_tokens Implements hook_tokens().
akamai_token_info Implements hook_token_info().