function views_aggregator_minimum in Views Aggregator Plus 8
Same name and namespace in other branches
- 7 views_aggregator_functions.inc \views_aggregator_minimum()
Aggregates a field group as the minimum across 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 find the minimum groups member in.
Return value
array An array of values, one for each group, plus the 'column' group.
1 string reference to 'views_aggregator_minimum'
- ViewsAggregatorResultsTest::testColumnResultFunctions in tests/
src/ Functional/ Plugin/ ViewsAggregatorResultsTest.php - Test the column functions.
File
Code
function views_aggregator_minimum(array $groups, $field_handler) {
$values = [];
foreach ($groups as $group => $rows) {
$is_first = TRUE;
$minimum = NULL;
foreach ($rows as $num => $row) {
$value = views_aggregator_get_cell($field_handler, $num, FALSE);
// Ignore empty strings.
if (isset($value) && trim($value) != '') {
if ($is_first) {
$minimum = $value;
$is_first = FALSE;
}
elseif ($value < $minimum) {
$minimum = $value;
}
}
}
if (isset($minimum)) {
$values[$group] = $minimum;
if (!isset($minimum_column) || $minimum < $minimum_column) {
$minimum_column = $minimum;
}
}
}
if (isset($minimum_column)) {
$values['column'] = $minimum_column;
}
return $values;
}