<?php

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

use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\nre_stations_entity_type\Entity\NreStationEckEntity;
use Drupal\nre_stations_entity_type\Service\Constants as NREStationEntityConstants;
use Drupal\Core\Url;
use Drupal\nre_train_operating_companies\Entity\NreTrainOperatingCompanyEckEntity;

/**
 * Preprocess hook for eck_entity__link_block__$ID().
 */
function toc_emr_preprocess_eck_entity__link_block__signup_link(&$vars) {
  $entity = $vars['elements']['#link_block'];
  $vars['block_class'] = 'bl-vh cbelianr bg-purple bl-lilfr py-lg-2 px-lg-3 mb-4 emr-lb-signup ';
  $vars['title_display'] = 'noflex';
}

/**
 * Preprocess hook for node__destination().
 *
 * @todo We have bundle name class. We need to differentiate them between
 * GA and WMR
 */
function toc_emr_preprocess_node__destination(&$vars) {
  if (isset($vars['form'])) {
    unset($vars['form']);
  }

  $entity = $vars['node'];
  // FAQs, let's use Routes.
  $vars['faqs'] = _tm_misc_destination_attraction_faqs($entity, 'field_dest_par_faqs');
  // Default area map, no marker required.
  $leaflet_map_format = _tm_leaflet_format(12, 0, 0, ['iconType' => 'html']);
  $map = _tm_misc_get_field_content($entity, 'field_dest_ge_location', 'render', $leaflet_map_format);
  $vars['map'] = $map;
  // Stations, needed for cards and locations.
  $vars['stations'] = _tm_misc_destination_attraction_maps($entity, 'field_dest_tp_stations_crs');
  // Extra info.
  $text_format = _tm_text_format([], 0, 'input', 'full_html');
  $vars['extra'] = _tm_misc_get_field_content($entity, 'field_dest_stf_extra_content', 'render', $text_format);
  $vars['swap_sidebar_form'] = TRUE;
}
