function StylePluginBase::render_grouping_sets

Render the grouping sets.

Plugins may override this method if they wish some other way of handling grouping.

Parameters

$sets: Array containing the grouping sets to render.

$level: Integer indicating the hierarchical level of the grouping.

Return value

string Rendered output of given grouping sets.

1 call to StylePluginBase::render_grouping_sets()
StylePluginBase::render in drupal/core/modules/views/lib/Drupal/views/Plugin/views/style/StylePluginBase.php
Render the display in this style.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/style/StylePluginBase.php, line 433
Definition of Drupal\views\Plugin\views\style\StylePluginBase.

Class

StylePluginBase
Base class to define a style plugin handler.

Namespace

Drupal\views\Plugin\views\style

Code

function render_grouping_sets($sets, $level = 0) {
  $output = array();
  $theme_functions = views_theme_functions('views_view_grouping', $this->view, $this->view->display_handler->display);
  foreach ($sets as $set) {
    $row = reset($set['rows']);

    // Render as a grouping set.
    if (is_array($row) && isset($row['group'])) {
      $output[] = array(
        '#theme' => $theme_functions,
        '#view' => $this->view,
        '#grouping' => $this->options['grouping'][$level],
        '#grouping_level' => $level,
        '#rows' => $set['rows'],
        '#title' => $set['group'],
      );
    }
    else {
      if ($this
        ->usesRowPlugin()) {
        foreach ($set['rows'] as $index => $row) {
          $this->view->row_index = $index;
          $render = $this->row_plugin
            ->render($row);

          // Row render arrays cannot be contained by style render arrays.
          $set['rows'][$index] = drupal_render($render);
        }
      }
      $output[] = array(
        '#theme' => $this
          ->themeFunctions(),
        '#view' => $this->view,
        '#options' => $this->options,
        '#grouping_level' => $level,
        '#rows' => $set['rows'],
        '#title' => $set['group'],
      );
    }
  }
  unset($this->view->row_index);
  return $output;
}