You are here

function site_settings_token_info in Site Settings and Labels 8

Implements hook_token_info().

File

./site_settings.tokens.inc, line 13
Builds placeholder replacement tokens for node-related data.

Code

function site_settings_token_info() {
  $types = [];
  $types['site_settings'] = [
    'name' => t("Site settings and labels"),
    'description' => t("Tokens for Site Settings and Labels."),
  ];
  $site_settings = [];

  // Dynamically generate the tokens for all available settings.
  $site_settings_loader = \Drupal::service('site_settings.loader');
  $settings = $site_settings_loader
    ->loadAll();
  if ($settings) {
    foreach ($settings as $fieldset => $fieldtypes) {
      foreach ($fieldtypes as $fieldtype => $values) {
        $site_settings = _site_settings_build_token($site_settings, $fieldset, $fieldtype, $values);
      }
    }
  }
  return [
    'types' => $types,
    'tokens' => [
      'site_settings' => $site_settings,
    ],
  ];
}