From 4dd251a1298fe201b87c303a933ba7c8ca7b9da3 Mon Sep 17 00:00:00 2001
From: Aivaras Gotovskis <aivaras.gotovskis@ongr.io>
Date: Thu, 9 Jul 2015 15:51:47 +0300
Subject: [PATCH] Add constructor arguments to GeoBoundsAggregation.

---
 src/Aggregation/GeoDistanceAggregation.php | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/Aggregation/GeoDistanceAggregation.php b/src/Aggregation/GeoDistanceAggregation.php
index d360bdf..b9a0e6f 100644
--- a/src/Aggregation/GeoDistanceAggregation.php
+++ b/src/Aggregation/GeoDistanceAggregation.php
@@ -40,6 +40,31 @@ class GeoDistanceAggregation extends AbstractAggregation
      */
     private $ranges = [];
 
+    /**
+     * Inner aggregations container init.
+     *
+     * @param string $name
+     * @param string $field
+     * @param mixed  $origin
+     * @param array  $ranges
+     * @param string $unit
+     * @param string $distanceType
+     */
+    public function __construct($name, $field = null, $origin = null, $ranges = [], $unit = null, $distanceType = null)
+    {
+        parent::__construct($name);
+
+        $this->setField($field);
+        $this->setOrigin($origin);
+        foreach ($ranges as $range) {
+            $from = isset($range['from']) ? $range['from'] : null;
+            $to = isset($range['to']) ? $range['to'] : null;
+            $this->addRange($from, $to);
+        }
+        $this->setUnit($unit);
+        $this->setDistanceType($distanceType);
+    }
+
     /**
      * @return string
      */
-- 
GitLab