You are here

function bootstrap_layout_builder_preprocess_row_columns in Bootstrap Layout Builder 1.x

Implements hook_preprocess_HOOK().

File

./bootstrap_layout_builder.module, line 44
Bootstrap Layout Builder module.

Code

function bootstrap_layout_builder_preprocess_row_columns(&$variables) {

  // Create an attributes variable for each region.
  $direct_attributes_mapping = [
    'container_wrapper',
    'container',
  ];
  $variables['video_background_url'] = NULL;
  foreach (Element::children($variables['content']) as $name) {
    if (in_array($name, $direct_attributes_mapping)) {
      if (isset($variables['content'][$name]['#attributes'])) {
        $variables[$name . '_attributes'] = new Attribute($variables['content'][$name]['#attributes']);
      }

      // video_background_url var.
      if ($name == 'container_wrapper') {
        if (isset($variables['content']['container_wrapper']['#video_background_url'])) {
          $variables['video_background_url'] = $variables['content']['container_wrapper']['#video_background_url'];
        }
        if (isset($variables['content']['container_wrapper']['#video_wrapper_classes'])) {
          $variables['video_wrapper_classes'] = $variables['content']['container_wrapper']['#video_wrapper_classes'];
        }
      }
    }
    if (!isset($variables['content'][$name]['#attributes'])) {
      $variables['content'][$name]['#attributes'] = [];
    }
    $variables['region_attributes'][$name] = new Attribute($variables['content'][$name]['#attributes']);
  }
}