<?php

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

/**
 * Preprocess hook for eck_entity__link_block__$ID().
 */
function toc_sr_preprocess_eck_entity__link_block__smartcard(&$vars) {
  $vars['block_class'] = 'bl-vh cbelianr bl-lilfr py-lg-2 px-lg-3 mb-4 sr-lb-signup';
  $vars['title_display'] = 'noflex';
}

/**
 * Preprocess hook for node__dog_offer().
 */
function toc_sr_preprocess_node__dog_offer(&$vars) {
  _toc_sr_preprocess_offers($vars);
}

/**
 * Preprocess hook for node__dog_offer().
 */
function toc_sr_preprocess_node__offer(&$vars) {
  _toc_sr_preprocess_offers($vars);
}

/**
 * Preprocess for both types of offer nodes.
 *
 * @param $vars
 *
 * @return void
 */
function _toc_sr_preprocess_offers(&$vars) {
  // Here we are formatting the back link. Everything else is from TOC Master.
  $entity = $vars['node'];
  $offers_config = \Drupal::service('config.factory')->getEditable('offers_content_type.settings');
  $back_link = $offers_config->get('offer_listings_path');
  $offer_category_terms_string = _tm_misc_get_field_content($entity, 'field_of_category');
  $tags = _tm_misc_format_tags_views_filter_links($offer_category_terms_string, $back_link, 'ocat');
  $vars['tags'] = $tags;
}
