function views_aggregator_sum in Views Aggregator Plus 8
Same name and namespace in other branches
- 7 views_aggregator_functions.inc \views_aggregator_sum()
Aggregates a field group as the sum of its members.
Parameters
array $groups: An array of groups of rows, each group indexed by group value.
object $field_handler: The handler for the view column to sum groups in.
Return value
array An array of values, one for each group, plus the 'column' group.
2 string references to 'views_aggregator_sum'
- Table::buildOptionsForm in src/
Plugin/ views/ style/ Table.php - Render the given style.
- views.view.va_test_style_table.yml in tests/
modules/ views_aggregator_test_config/ test_views/ views.view.va_test_style_table.yml - tests/modules/views_aggregator_test_config/test_views/views.view.va_test_style_table.yml
File
Code
function views_aggregator_sum(array $groups, $field_handler) {
$values = [];
$sum_column = 0.0;
foreach ($groups as $group => $rows) {
$sum = 0.0;
foreach ($rows as $num => $row) {
$cell = vap_num(views_aggregator_get_cell($field_handler, $num, FALSE));
if ($cell !== FALSE) {
$sum += $cell;
}
}
$values[$group] = $sum;
$sum_column += $sum;
}
$values['column'] = $sum_column;
return $values;
}