You are here

function template_preprocess_bat_fullcalendar in Booking and Availability Management Tools for Drupal 8

Theme function for FullCalendar

File

modules/bat_fullcalendar/bat_fullcalendar.module, line 218
Manages the display of FullCalendar and provides ways for other modules to easily modify it.

Code

function template_preprocess_bat_fullcalendar(&$variables) {
  $calendar_id = $variables['calendar_settings']['calendar_id'];
  $user_settings = $variables['calendar_settings']['user_settings'];

  // Attributes.
  if (!empty($variables['attributes'])) {
    $attributes = $variables['attributes'];
  }
  else {
    $attributes = [
      'id' => Html::getUniqueId('calendar'),
      'class' => [
        'calendar-set',
        'clearfix',
      ],
    ];
    if (isset($variables['calendar_settings']['class']) && !empty($variables['calendar_settings']['class'])) {
      $attributes['class'] = array_merge($attributes['class'], $variables['calendar_settings']['class']);
    }
  }

  // Override default settings with ones coming from the user.
  $settings = bat_fullcalendar_configure($variables['calendar_settings']['user_settings']);
  $settings['batCalendar'][0]['id'] = $attributes['id'];
  $attributes = new Attribute($attributes);
  $variables['#attached'] = [
    'library' => [
      'bat_fullcalendar/fullcalendar-scheduler',
    ],
    'drupalSettings' => $settings,
  ];
  $variables['content'] = [
    '#markup' => '<div' . $attributes
      ->__toString() . '></div>',
  ];
}