You are here

function bat_event_views_pre_render in Booking and Availability Management Tools for Drupal 8

Same name and namespace in other branches
  1. 7 modules/bat_event/bat_event.module \bat_event_views_pre_render()

Implements hook_views_pre_render().

File

modules/bat_event/bat_event.module, line 844
Manage Events - Events store the EventValue of a Unit over a period of time.

Code

function bat_event_views_pre_render(ViewExecutable $view) {

  // Use "BAT PHP Date Format" for event Start date and End date.
  if (in_array('event', $view
    ->getBaseTables())) {
    $date_format = \Drupal::config('bat.settings')
      ->get('date_format') ?: 'Y-m-d H:i';
    if (isset($view->field['start_date']->options['custom_date_format'])) {
      $view->field['start_date']->options['custom_date_format'] = $date_format;
    }
    if (isset($view->field['end_date']->options['custom_date_format'])) {
      $view->field['end_date']->options['custom_date_format'] = $date_format;
    }
  }
}