You are here

protected function FullCalendar::prepareSettings in FullCalendar 8.3

Same name and namespace in other branches
  1. 8.5 src/Plugin/views/style/FullCalendar.php \Drupal\fullcalendar\Plugin\views\style\FullCalendar::prepareSettings()
  2. 8 src/Plugin/views/style/FullCalendar.php \Drupal\fullcalendar\Plugin\views\style\FullCalendar::prepareSettings()
  3. 8.2 src/Plugin/views/style/FullCalendar.php \Drupal\fullcalendar\Plugin\views\style\FullCalendar::prepareSettings()
  4. 8.4 src/Plugin/views/style/FullCalendar.php \Drupal\fullcalendar\Plugin\views\style\FullCalendar::prepareSettings()

Prepare JavaScript settings.

Throws

\Exception

1 call to FullCalendar::prepareSettings()
FullCalendar::prepareAttached in src/Plugin/views/style/FullCalendar.php
Load libraries.

File

src/Plugin/views/style/FullCalendar.php, line 323

Class

FullCalendar
Plugin annotation @ViewsStyle( id = "fullcalendar", title = @Translation("FullCalendar"), help = @Translation("Displays items on a calendar."), theme = "fullcalendar", theme_file = "fullcalendar.theme.inc", display_types = {"normal"} )

Namespace

Drupal\fullcalendar\Plugin\views\style

Code

protected function prepareSettings() {
  $settings =& drupal_static(__METHOD__, []);
  if (empty($settings)) {
    $weights = [];
    $delta = 0;

    /* @var \Drupal\fullcalendar\Plugin\fullcalendar\type\FullCalendar $plugin */
    foreach ($this
      ->getPlugins() as $plugin_id => $plugin) {
      $definition = $plugin
        ->getPluginDefinition();
      $plugin
        ->process($settings);
      if (isset($definition['weight']) && !isset($weights[$definition['weight']])) {
        $weights[$definition['weight']] = $plugin_id;
      }
      else {
        while (isset($weights[$delta])) {
          $delta++;
        }
        $weights[$delta] = $plugin_id;
      }
    }
    ksort($weights);
    $settings['weights'] = array_values($weights);

    // TODO
    $settings['fullcalendar']['disableResizing'] = TRUE;

    // Force to disable dates in the previous or next month in order to get
    // the (real) first and last day of the current month after using pager in
    // 'month' view. So, disabling this results a valid date-range for the
    // current month, instead of the date-range +/- days from the previous and
    // next month. It's very important, because we set default date-range in
    // the same way in fullcalendar_views_pre_view().
    // @see https://fullcalendar.io/docs/display/showNonCurrentDates/
    $settings['fullcalendar']['showNonCurrentDates'] = FALSE;
    $settings['fullcalendar']['fixedWeekCount'] = FALSE;

    // Need to reverse this value.
    if (empty($settings['fullcalendar']['editable'])) {
      $settings['fullcalendar']['editable'] = TRUE;
    }
    else {
      $settings['fullcalendar']['editable'] = FALSE;
    }
    $settings['fullcalendar']['locale'] = \Drupal::languageManager()
      ->getCurrentLanguage()
      ->getId();
  }
  $settings['fullcalendar']['_events'] = $this
    ->prepareEvents();
  return $settings;
}