<?php

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

use Drupal\Component\Utility\Html;

/**
 * Preprocess for Stations list block.
 */
function toc_emr_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',
    ];
  }
}
