Skip to content

Commit

Permalink
fixes #257 - added $format arg to date histogram (#259)
Browse files Browse the repository at this point in the history
* fixes #257 - added $format arg to date histogram

* fixed typo
  • Loading branch information
zoul0813 authored and saimaz committed May 3, 2018
1 parent b566808 commit 4e7e235
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Aggregation/Bucketing/DateHistogramAggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,25 @@ class DateHistogramAggregation extends AbstractAggregation
*/
protected $interval;

/**
* @var string
*/
protected $format;

/**
* Inner aggregations container init.
*
* @param string $name
* @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);
}

/**
Expand All @@ -59,6 +65,14 @@ public function setInterval($interval)
$this->interval = $interval;
}

/**
* @param string $format
*/
public function setFormat($format)
{
$this->format = $format;
}

/**
* {@inheritdoc}
*/
Expand All @@ -81,6 +95,10 @@ public function getArray()
'interval' => $this->getInterval(),
];

if (!empty($this->format)) {
$out['format'] = $this->format;
}

return $out;
}
}

0 comments on commit 4e7e235

Please sign in to comment.