You are here

public function SlickGrouping::renderGrouping in Slick Views 8.2

Overrides StylePluginBase::renderGrouping().

File

src/Plugin/views/style/SlickGrouping.php, line 229

Class

SlickGrouping
Slick style plugin with grouping support.

Namespace

Drupal\slick_views\Plugin\views\style

Code

public function renderGrouping($records, $groupings = [], $group_rendered = NULL) {
  $sets = parent::renderGrouping($records, $groupings, $group_rendered);
  $grouping = empty($groupings) ? [] : array_filter($groupings);

  // Only add limits for the first top level grouping to avoid recursiveness.
  if (!empty($grouping) && !empty($this->options['grouping_limit'])) {
    $new_sets = array_values($sets);
    $sets = [];
    foreach ($new_sets as $set) {
      $set['rows'] = array_slice($set['rows'], 0, $this->options['grouping_limit'], TRUE);
      $sets[] = $set;
    }
  }
  return $sets;
}