<?php

/**
 * @file
 * Functions to support theming blocks in the Toc Master theme.
 */

use Drupal\block\Entity\Block;
use Drupal\Core\Template\Attribute;

/**
 * Implements hook_preprocess_HOOK().
 *
 * Pass block region value to content so this can be used in
 * MYTHEME_theme_suggestions_menu_alter.
 */
function toc_wmr_preprocess_block(&$vars) {

  // Hide contextual links from all blocks in the list.
  $blocks_hide_context_links = [
    'footerlogo',
  ];
  $id = $vars['elements']['#id'] ?? '';
  if (in_array($id, $blocks_hide_context_links)) {
    if (!empty($vars['title_suffix']) && !empty($vars['title_suffix']['contextual_links'])) {
      unset($vars['title_suffix']['contextual_links']);
    }
  }
}

function toc_wmr_preprocess_journey_smart_live_times_block(&$vars) {
  $vars['#attached']['library'][] = 'toc_wmr/feature_block__journey_smart_live_times';
}

/**
 * Preprocess for blocks in footer top group.
 *
 * Any block (or block group) in this region gets equal cols.
 *
 * @see block--blockgroup--footer-top.html.twig
 */
function toc_wmr_preprocess_block__blockgroup__footer_top(&$vars) {
  $vars['cols'] = "col-md-3";
}

/**
 * Implements hook_preprocess_journey_smart_booking_form().)
 */
function toc_wmr_preprocess_journey_smart_booking_form(&$vars) {
  $vars['#attached']['library'][] = 'toc_wmr/feature_block__journey_smart_booking_form';
}
