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
*/
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 @@ class DateHistogramAggregation extends AbstractAggregation
$this->interval = $interval;
}
/**
* @param string $format
*/
public function setFormat($format)
{
$this->format = $format;
}
/**
* {@inheritdoc}
*/
......@@ -81,6 +95,10 @@ class DateHistogramAggregation extends AbstractAggregation
'interval' => $this->getInterval(),
];
if (!empty($this->format)) {
$out['format'] = $this->format;
}
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