You are here

function domain_preprocess_html in Domain Access 8

Same name and namespace in other branches
  1. 7.3 domain.module \domain_preprocess_html()

Implements hook_preprocess_HOOK() for html.html.twig.

File

domain/domain.module, line 84
Defines a Domain concept for use with Drupal.

Code

function domain_preprocess_html(array &$variables) {

  // Add class to body tag, if set.
  $config = \Drupal::config('domain.settings');
  if ($string = $config
    ->get('css_classes')) {
    $token = \Drupal::token();

    // Prepare the classes proparly, with one class per string.
    $classes = explode(' ', trim($string));
    foreach ($classes as $class) {

      // Ensure no leading or trailing space.
      $class = trim($class);
      if (!empty($class)) {
        $variables['attributes']['class'][] = Html::getClass($token
          ->replace($class));
      }
    }
  }
}