<?php

/**
 * @file
 * Functions to support views.
 */

use Drupal\Component\Utility\Html;

/**
 * Preprocess for Stations list block.
 */
function toc_ga_preprocess_views_view__stations__block_1(&$vars) {
  $pid = Html::getUniqueId('st-atoz');
  $items = [];
  $vars['ac_vars'] = FALSE;
  if (!empty($vars["rows"])) {
    foreach ($vars["rows"] as $row) {
      $title = strip_tags($row['#title']);
      $aiid = Html::getUniqueId('st-atoz-' . $title);
      $items[] = [
        "pid" => $pid,
        "aiid" => $aiid,
        "label" => $title,
        "content" => $row,
      ];
    }
  }
  if (!empty($items)) {
    $vars['ac_vars'] = [
      'pid' => $pid,
      'items' => $items,
      'wrapper_class' => 'mt-3',
    ];
  }
}

function toc_ga_preprocess_views_view__service_announcements_frontend_views__service_announcements_above_banner(&$vars) {
  if (!empty($vars['items'])) {
    foreach ($vars['items'] as &$item) {
      $item['extra'] = '';
    }
  }
}
