Skip to content
Snippets Groups Projects
Commit 4e7e2352 authored by David Higgins's avatar David Higgins Committed by Simonas Šerlinskas
Browse files

fixes #257 - added $format arg to date histogram (#259)

* fixes #257 - added $format arg to date histogram

* fixed typo
parent b566808b
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,11 @@ class DateHistogramAggregation extends AbstractAggregation ...@@ -28,6 +28,11 @@ class DateHistogramAggregation extends AbstractAggregation
*/ */
protected $interval; protected $interval;
/**
* @var string
*/
protected $format;
/** /**
* Inner aggregations container init. * Inner aggregations container init.
* *
...@@ -35,12 +40,13 @@ class DateHistogramAggregation extends AbstractAggregation ...@@ -35,12 +40,13 @@ class DateHistogramAggregation extends AbstractAggregation
* @param string $field * @param string $field
* @param string $interval * @param string $interval
*/ */
public function __construct($name, $field = null, $interval = null) public function __construct($name, $field = null, $interval = null, $format = null)
{ {
parent::__construct($name); parent::__construct($name);
$this->setField($field); $this->setField($field);
$this->setInterval($interval); $this->setInterval($interval);
$this->setFormat($format);
} }
/** /**
...@@ -59,6 +65,14 @@ class DateHistogramAggregation extends AbstractAggregation ...@@ -59,6 +65,14 @@ class DateHistogramAggregation extends AbstractAggregation
$this->interval = $interval; $this->interval = $interval;
} }
/**
* @param string $format
*/
public function setFormat($format)
{
$this->format = $format;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -81,6 +95,10 @@ class DateHistogramAggregation extends AbstractAggregation ...@@ -81,6 +95,10 @@ class DateHistogramAggregation extends AbstractAggregation
'interval' => $this->getInterval(), 'interval' => $this->getInterval(),
]; ];
if (!empty($this->format)) {
$out['format'] = $this->format;
}
return $out; return $out;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment