public function ViewsAutorefreshArea::render in Views Autorefresh D8 port 8
Render the area.
Parameters
bool $empty: (optional) Indicator if view result is empty or not. Defaults to FALSE.
Return value
array In any case we need a valid Drupal render array to return.
Overrides AreaPluginBase::render
File
- src/
Plugin/ views/ area/ ViewsAutorefreshArea.php, line 42
Class
- ViewsAutorefreshArea
- Defines an area plugin for the Autorefresh header.
Namespace
Drupal\views_autorefresh_d8\Plugin\views\areaCode
public function render($empty = FALSE) {
$view = $this->view;
$interval = $this->options['interval'];
// Attach the views_autorefresh library and the settings.
$build['#attached']['library'][] = 'views_autorefresh_d8/views_autorefresh';
$build['#attached']['drupalSettings']['views_autorefresh'][$view
->id()][$view->current_display] = $interval;
// Enable ajax, attach views.ajax library and add the view to
// drupalSettings.
$view
->setAjaxEnabled(TRUE);
views_views_pre_render($view);
return $build;
}