From 4e7e235284e9cb69a93cc89b9de8daec14704664 Mon Sep 17 00:00:00 2001 From: David Higgins Date: Thu, 3 May 2018 10:10:21 -0400 Subject: [PATCH] fixes #257 - added $format arg to date histogram (#259) * fixes #257 - added $format arg to date histogram * fixed typo --- .../Bucketing/DateHistogramAggregation.php | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Aggregation/Bucketing/DateHistogramAggregation.php b/src/Aggregation/Bucketing/DateHistogramAggregation.php index 58abbc05..4b1009d3 100644 --- a/src/Aggregation/Bucketing/DateHistogramAggregation.php +++ b/src/Aggregation/Bucketing/DateHistogramAggregation.php @@ -28,6 +28,11 @@ class DateHistogramAggregation extends AbstractAggregation */ protected $interval; + /** + * @var string + */ + protected $format; + /** * Inner aggregations container init. * @@ -35,12 +40,13 @@ class DateHistogramAggregation extends AbstractAggregation * @param string $field * @param string $interval */ - public function __construct($name, $field = null, $interval = null) + public function __construct($name, $field = null, $interval = null, $format = null) { parent::__construct($name); $this->setField($field); $this->setInterval($interval); + $this->setFormat($format); } /** @@ -59,6 +65,14 @@ public function setInterval($interval) $this->interval = $interval; } + /** + * @param string $format + */ + public function setFormat($format) + { + $this->format = $format; + } + /** * {@inheritdoc} */ @@ -81,6 +95,10 @@ public function getArray() 'interval' => $this->getInterval(), ]; + if (!empty($this->format)) { + $out['format'] = $this->format; + } + return $out; } }