You are here

protected function FullCalendar::prepareAttached in FullCalendar 8

Same name and namespace in other branches
  1. 8.5 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
Render the display in this style.

File

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

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 prepareAttached() {

  /* @var \Drupal\fullcalendar\Plugin\fullcalendar\type\FullCalendar $plugin */
  $attached['library'][] = 'fullcalendar/drupal.fullcalendar';
  foreach ($this
    ->getPlugins() as $plugin_id => $plugin) {
    $definition = $plugin
      ->getPluginDefinition();
    foreach ([
      'css',
      'js',
    ] as $type) {
      if ($definition[$type]) {
        $attached['library'][] = $definition['provider'] . '/drupal.' . $plugin_id . '.' . $type;
      }
    }
  }
  if ($this->displayHandler
    ->getOption('use_ajax')) {
    $attached['library'][] = 'fullcalendar/drupal.fullcalendar.ajax';
  }
  $settings = $this
    ->prepareSettings();
  $attached['drupalSettings']['fullcalendar'] = [
    '.js-view-dom-id-' . $this->view->dom_id => $settings,
  ];
  if (!empty($settings['fullcalendar']['modalWindow'])) {

    // FIXME all of these libraries are needed?
    $attached['library'][] = 'core/drupal.ajax';
    $attached['library'][] = 'core/drupal.dialog';
    $attached['library'][] = 'core/drupal.dialog.ajax';
  }
  return $attached;
}