You are here

protected function SettingsForm::setTokenDescription in Instagram Feeds 8

Creates element array keys with token suggestions.

Parameters

array $types: The list of allowed token types. If empty, all global types will be allowed.

Return value

$this

1 call to SettingsForm::setTokenDescription()
SettingsForm::getTokenDescription in src/Form/SettingsForm.php
Returns form element array with token suggestions.

File

src/Form/SettingsForm.php, line 200

Class

SettingsForm
Defines an Instagram Feeds configuration form.

Namespace

Drupal\instagram_feeds\Form

Code

protected function setTokenDescription(array $types = []) {
  sort($types);
  $key = md5(serialize($types));
  $this->tokenDescription[$key] = [];
  if (\Drupal::moduleHandler()
    ->moduleExists('token')) {
    $token_tree = [
      '#theme' => 'token_tree_link',
      '#token_types' => $types,
      '#global_types' => count($types) ? FALSE : TRUE,
      '#click_insert' => TRUE,
    ];
    $this->tokenDescription[$key] = [
      '#field_suffix' => $this
        ->t('This field supports tokens. @browse_tokens_link', [
        '@browse_tokens_link' => \Drupal::service('renderer')
          ->render($token_tree),
      ]),
      '#element_validate' => [
        'token_element_validate',
      ],
      '#token_types' => $types,
    ];
  }
  return $this;
}