You are here

protected function Table::executeAggregationFunctions in Views Aggregator Plus 8

Executes the supplied aggregation functions with the groups as arguments.

Parameters

array $groups: Groups of aggregated rows.

array $functions: Aggregation functions to use.

Return value

array Function return values.

1 call to Table::executeAggregationFunctions()
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 513

Class

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

Namespace

Drupal\views_aggregator\Plugin\views\style

Code

protected function executeAggregationFunctions(array $groups, array $functions) {
  $field_handlers = $this->view->field;
  $values = [];
  foreach ($functions as $field_name => $field_functions) {
    if (empty($field_handlers[$field_name])) {
      continue;
    }
    $options = $this->options['info'][$field_name];
    foreach ($field_functions as $function) {
      $group_par = !isset($options['aggr_par']) || $options['aggr_par'] == '' ? NULL : $options['aggr_par'];
      $column_par = !isset($options['aggr_par_column']) || $options['aggr_par_column'] == '' ? NULL : $options['aggr_par_column'];
      $aggr_values = $function($groups, $field_handlers[$field_name], $group_par, $column_par);

      // $aggr_values is indexed by group value and/or 'column'.
      // 'column' is the last evaluated value for the field.
      if (isset($aggr_values['column'])) {
        $field_handlers[$field_name]->last_render = $aggr_values['column'];
      }
      foreach ($aggr_values as $group => $value) {

        // 'column' function is last so may override earlier value.
        if (!isset($values[$field_name][$group]) || $group == 'column') {
          $values[$field_name][$group] = $value;
        }
      }
    }
  }
  return $values;
}