You are here

function template_preprocess_webform_help in Webform 6.x

Same name and namespace in other branches
  1. 8.5 includes/webform.theme.template.inc \template_preprocess_webform_help()

Prepares variables for webform help templates.

Default template: webform_help.html.twig.

Parameters

array $variables: An associative array containing:

  • title: Help title.
  • content: Help content.

File

includes/webform.theme.template.inc, line 35
Preprocessors and helper functions to make theming easier.

Code

function template_preprocess_webform_help(array &$variables) {

  /** @var \Drupal\webform\WebformHelpManagerInterface $help_manager */
  $help_manager = \Drupal::service('webform.help_manager');
  $help_info = $variables['info'];
  $variables += $help_info;
  $help = [];

  // Content.
  if (is_array($help_info['content'])) {
    $help['content'] = $help_info['content'];
  }
  else {
    $help['content'] = [
      '#markup' => $help_info['content'],
    ];
  }

  // Video.
  $video_info = isset($help_info['video_id']) ? $help_manager
    ->getVideo($help_info['video_id']) : $help_info;
  if (isset($video_info['id'])) {
    $help['link'] = $help_manager
      ->buildVideoLink($video_info['id']);
  }
  $variables['help'] = $help;
}