You are here

protected function Table::aggregateGroups in Views Aggregator Plus 8

Aggregate and compress the View's rows into groups.

Return value

array An array of aggregated groups.

1 call to Table::aggregateGroups()
Table::preRender in src/Plugin/views/style/Table.php
Note that this class being a views_plugin, rather than a views_handler, it does not have a post_execute() function.

File

src/Plugin/views/style/Table.php, line 453

Class

Table
Style plugin to render each item as a row in a table.

Namespace

Drupal\views_aggregator\Plugin\views\style

Code

protected function aggregateGroups() {
  $field_handlers = $this->view->field;

  // Find the one column to group by and execute the grouping.
  foreach ($this->options['info'] as $field_name => $options) {
    if (!empty($options['has_aggr']) && in_array('views_aggregator_group_and_compress', $options['aggr'], FALSE)) {
      $groups = views_aggregator_group_and_compress($this->view->result, $field_handlers[$field_name], $options['aggr_par']);
      break;
    }
  }
  if (empty($groups)) {

    // If there are no regular groups, create a special group for column
    // aggregation. This group holds all View result rows.
    foreach ($this->view->result as $num => $row) {
      $groups['column'][$num] = $row;
    }
  }
  return $groups;
}