public function GridStackViews::render in GridStack 8
Same name and namespace in other branches
- 8.2 src/Plugin/views/style/GridStackViews.php \Drupal\gridstack\Plugin\views\style\GridStackViews::render()
Overrides StylePluginBase::render().
File
- src/
Plugin/ views/ style/ GridStackViews.php, line 88
Class
- GridStackViews
- GridStack style plugin.
Namespace
Drupal\gridstack\Plugin\views\styleCode
public function render() {
$blazy = $this
->blazyManager();
$view = $this->view;
$settings = $this->options + GridStackDefault::entitySettings();
$view_name = $view->storage
->id();
$view_mode = $view->current_display;
$count = count($view->result);
$id = Blazy::getHtmlId("gridstack-{$view_name}-{$view_mode}", $settings['id']);
$optionset = GridStack::load($settings['optionset']);
$grids = $optionset
->getEndBreakpointGrids();
$settings += [
'cache_metadata' => [
'keys' => [
$id,
$view_mode,
$settings['optionset'],
],
],
'count' => $count,
'current_view_mode' => $view_mode,
'view_name' => $view_name,
];
// Grids: x y width height image_style
// Breakpoints: xs sm md lg, may contain width column image_style grids.
$settings['id'] = $id;
$settings['item_id'] = 'box';
$settings['caption'] = array_filter($settings['caption']);
$settings['namespace'] = 'gridstack';
$settings['ratio'] = '';
$settings['_views'] = TRUE;
// Converts gridstack breakpoint grids from stored JSON into array.
$optionset
->gridsJsonToArray($settings);
$elements = [];
foreach ($this
->renderGrouping($view->result, $settings['grouping']) as $rows) {
$settings = array_filter($settings);
$items = $this
->buildElements($settings, $rows, $grids);
// Supports Blazy formatter multi-breakpoint images if available.
$blazy
->isBlazy($settings, $items[0]);
$build = [
'items' => $items,
'optionset' => $optionset,
'settings' => $settings,
];
$elements = $this->manager
->build($build);
unset($build);
}
return $elements;
}