You are here

protected function AdminSettingsForm::buildTokenElement in SMS Framework 8

Build a token element.

Return value

array A render array.

1 call to AdminSettingsForm::buildTokenElement()
AdminSettingsForm::buildForm in modules/sms_user/src/Form/AdminSettingsForm.php
Form constructor.

File

modules/sms_user/src/Form/AdminSettingsForm.php, line 471

Class

AdminSettingsForm
Provides a general settings form for SMS User.

Namespace

Drupal\sms_user\Form

Code

protected function buildTokenElement() {
  $tokens = [
    'sms-message',
    'user',
  ];

  /** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */
  $module_handler = \Drupal::service('module_handler');
  if ($module_handler
    ->moduleExists('token')) {
    return [
      '#theme' => 'token_tree_link',
      '#token_types' => $tokens,
    ];
  }
  else {
    foreach ($tokens as &$token) {
      $token = "[{$token}:*]";
    }
    return [
      '#markup' => $this
        ->t('Available tokens include: @token_types', [
        '@token_types' => implode(' ', $tokens),
      ]),
    ];
  }
}