You are here

function background_image_token_info_alter in Background Image 8

Same name and namespace in other branches
  1. 2.x background_image.module \background_image_token_info_alter()
  2. 2.0.x background_image.module \background_image_token_info_alter()

Implements hook_token_info_alter().

File

./background_image.module, line 156
Background Image module's procedural hooks and functions.

Code

function background_image_token_info_alter(&$data) {
  $types = array_map(function (EntityTypeInterface $entityType) {
    return $entityType
      ->id();
  }, BackgroundImageManager::service()
    ->getEnabledEntityTypes()) + [
    'current-page',
    'site',
  ];

  // Modify description of node tokens for our site.
  foreach ($types as $type) {

    // Skip tokens that don't exist.
    if (!isset($data['tokens'][$type])) {
      continue;
    }
    $data['tokens'][$type]['background_image'] = [
      'name' => t('Background Image'),
      'description' => t('The background image.'),
      'type' => 'background_image',
      'module' => 'background_image',
    ];
  }
}