You are here

public function GridStackViews::render in GridStack 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/views/style/GridStackViews.php \Drupal\gridstack\Plugin\views\style\GridStackViews::render()

Overrides StylePluginBase::render().

File

src/Plugin/views/style/GridStackViews.php, line 121

Class

GridStackViews
GridStack style plugin.

Namespace

Drupal\gridstack\Plugin\views\style

Code

public function render() {
  $settings = $this
    ->buildSettings();
  $optionset = GridStack::loadWithFallback($settings['optionset']);
  $elements = [];
  foreach ($this
    ->renderGrouping($this->view->result, $settings['grouping']) as $rows) {
    $settings = array_filter($settings, function ($value) {
      return $value !== NULL && $value !== '' && $value !== [];
    });
    $items = $this
      ->buildElements($settings, $rows);

    // Supports Blazy multi-breakpoint images if using Blazy formatter.
    $settings['first_image'] = isset($rows[0]) ? $this
      ->getFirstImage($rows[0]) : [];
    $build = [
      'items' => $items,
      'optionset' => $optionset,
      'settings' => $settings,
    ];
    $elements = $this->manager
      ->build($build);
    unset($build);
  }
  return $elements;
}