hydrateEntityAggregation example

return new StatsResult($aggregation->getName(), 0, 0, 0.0, 0.0);
                }

                $min = $rows[0][$name . '.min'] ?? null;
                $max = $rows[0][$name . '.max'] ?? null;
                $avg = isset($rows[0][$name . '.avg']) ? (float) $rows[0][$name . '.avg'] : null;
                $sum = isset($rows[0][$name . '.sum']) ? (float) $rows[0][$name . '.sum'] : null;

                return new StatsResult($aggregation->getName()$min$max$avg$sum);

            case $aggregation instanceof EntityAggregation:
                return $this->hydrateEntityAggregation($aggregation$rows$context);
            case $aggregation instanceof RangeAggregation:
                return $this->hydrateRangeAggregation($aggregation$rows);
            default:
                throw new InvalidAggregationQueryException(sprintf('Aggregation of type %s not supported', $aggregation::class));
        }
    }

    /** * @param array<array<string, mixed>> $rows */
    private function hydrateEntityAggregation(
        
switch (true) {
            case $aggregation instanceof StatsAggregation:
                return new StatsResult($aggregation->getName()$result['min']$result['max']$result['avg']$result['sum']);

            case $aggregation instanceof AvgAggregation:
                return new AvgResult($aggregation->getName()$result['value']);

            case $aggregation instanceof CountAggregation:
                return new CountResult($aggregation->getName()$result['value']);

            case $aggregation instanceof EntityAggregation:
                return $this->hydrateEntityAggregation($aggregation$result$context);

            case $aggregation instanceof MaxAggregation:
                return new MaxResult($aggregation->getName()$result['value']);

            case $aggregation instanceof MinAggregation:
                return new MinResult($aggregation->getName()$result['value']);

            case $aggregation instanceof SumAggregation:
                return new SumResult($aggregation->getName()$result['value']);

            case $aggregation instanceof FilterAggregation:
                
Home | Imprint | This part of the site doesn't use cookies.