You are here

protected function FullCalendar::prepareAttached in FullCalendar 8.5

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

Load libraries.

Throws

\Exception

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

File

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

Class

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

Namespace

Drupal\fullcalendar\Plugin\views\style

Code

protected function prepareAttached() {

  /* @var \Drupal\fullcalendar\Plugin\fullcalendar\type\FullCalendar $plugin */
  $attached['library'][] = 'fullcalendar/drupal.fullcalendar';
  $settings = $this
    ->prepareSettings();

  // Only attach assets for enabled FC plugins.
  $fcPlugins = !empty($settings['options']['plugins']) ? $settings['options']['plugins'] : [
    'dayGrid',
  ];
  foreach ($fcPlugins as $fcPlugin) {
    $attached['library'][] = 'fullcalendar/fullcalendar.' . strtolower($fcPlugin);
  }
  if (!empty($settings['options']['themeSystem']) && $settings['options']['themeSystem'] === 'bootstrap') {
    $attached['library'][] = 'fullcalendar/fullcalendar.bootstrap';
  }
  $attached['drupalSettings']['fullcalendar'] = [
    'js-view-dom-id-' . $this->view->dom_id => $settings,
  ];
  return $attached;
}