diff --git a/src/Aggregation/DateRangeAggregation.php b/src/Aggregation/DateRangeAggregation.php index ff445055b318dce8a2c7cb6ef29135387dcd4a69..b70da8f94ed621464a8b6c6d15d3b3409a967b95 100644 --- a/src/Aggregation/DateRangeAggregation.php +++ b/src/Aggregation/DateRangeAggregation.php @@ -33,6 +33,24 @@ class DateRangeAggregation extends AbstractAggregation return $this->format; } + /** + * @param string $name + * @param string $field + * @param string $format + * @param array $ranges + */ + public function __construct($name, $field = null, $format = null, array $ranges = []) + { + parent::__construct($name, $field); + + $this->setFormat($format); + foreach ($ranges as $range) { + $from = isset($range['from']) ? $range['from'] : null; + $to = isset($range['to']) ? $range['to'] : null; + $this->addRange($from, $to); + } + } + /** * @param string $format */