You are here

public function BlazyViews::render in Blazy 7

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/style/BlazyViews.php \Drupal\blazy\Plugin\views\style\BlazyViews::render()
  2. 8 src/Plugin/views/style/BlazyViews.php \Drupal\blazy\Plugin\views\style\BlazyViews::render()

Overrides StylePluginBase::render().

Overrides views_plugin_style::render

File

src/Plugin/views/style/BlazyViews.php, line 65

Class

BlazyViews
Blazy style plugin.

Namespace

Drupal\blazy\Plugin\views\style

Code

public function render() {
  $settings = $this
    ->buildSettings();
  $settings['item_id'] = 'content';
  $settings['namespace'] = 'blazy';
  $elements = [];
  foreach ($this
    ->render_grouping($this->view->result, $settings['grouping']) as $rows) {
    $items = [];
    foreach ($rows as $index => $row) {
      $this->view->row_index = $index;
      $items[$index] = $this->view->style_plugin->row_plugin
        ->render($row);
    }

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