You are here

function template_preprocess_quail_api_problem in Quail API 8

Same name and namespace in other branches
  1. 7 quail_api.module \template_preprocess_quail_api_problem()

Template preprocess function for quail_api_problem.tpl.php.

File

./quail_api.module, line 216
Module file for the quail api.

Code

function template_preprocess_quail_api_problem(&$variables) {
  $root_class_name = 'quail_api-problem';
  if (!isset($variables['quail_base_class'])) {
    $variables['quail_base_class'] = $root_class_name;
  }
  if (!isset($variables['quail_specific_class'])) {
    $variables['quail_specific_class'] = '';
  }
  if (!isset($variables['quail_problem_line'])) {
    $variables['quail_problem_line'] = '';
  }
  if (!isset($variables['quail_problem_description'])) {
    $variables['quail_problem_description'] = '';
  }
  if (isset($variables['quail_problem_id'])) {
    $variables['quail_specific_class'] = $root_class_name . '-' . Drupal\Component\Utility\Unicode::strtolower(\Drupal\Component\Utility\Html::escape($variables['quail_problem_id']));
  }
  if (isset($variables['quail_problem_data']['line'])) {
    $variables['quail_problem_line'] = '' . $variables['quail_problem_data']['line'];
  }
  $fallback_filter_format = filter_fallback_format();
  if (isset($variables['quail_problem_data']['element'])) {

    // drupal 8.4 and earlier seem to have issues with NULL being passed as the markup format.
    if (is_null($variables['quail_markup_format'])) {
      $variables['quail_problem_description'] = check_markup($variables['quail_problem_data']['element'], $fallback_filter_format);
    }
    else {
      $variables['quail_problem_description'] = check_markup($variables['quail_problem_data']['element'], $variables['quail_markup_format']);
    }
  }
  unset($variables['quail_problem_id']);
  unset($variables['quail_problem_data']);
}