|
11 | 11 |
|
12 | 12 | namespace ONGR\ElasticsearchDSL\Filter; |
13 | 13 |
|
14 | | -use ONGR\ElasticsearchDSL\BuilderInterface; |
15 | | -use ONGR\ElasticsearchDSL\ParametersTrait; |
| 14 | +@trigger_error( |
| 15 | + 'The GeoBoundingBoxFilter class is deprecated and will be removed in 2.0. Use GeoBoundingBoxQuery instead.', |
| 16 | + E_USER_DEPRECATED |
| 17 | +); |
| 18 | + |
| 19 | +use ONGR\ElasticsearchDSL\Query\GeoBoundingBoxQuery; |
16 | 20 |
|
17 | 21 | /** |
18 | 22 | * Represents Elasticsearch "Geo Bounding Box" filter. |
| 23 | + * |
| 24 | + * @deprecated Will be removed in 2.0. Use the GeoBoundingBoxQuery instead. |
19 | 25 | */ |
20 | | -class GeoBoundingBoxFilter implements BuilderInterface |
| 26 | +class GeoBoundingBoxFilter extends GeoBoundingBoxQuery |
21 | 27 | { |
22 | | - use ParametersTrait; |
23 | | - |
24 | | - /** |
25 | | - * @var array |
26 | | - */ |
27 | | - private $values; |
28 | | - |
29 | | - /** |
30 | | - * @var string |
31 | | - */ |
32 | | - private $field; |
33 | | - |
34 | | - /** |
35 | | - * @param string $field |
36 | | - * @param array $values |
37 | | - * @param array $parameters |
38 | | - */ |
39 | | - public function __construct($field, $values, array $parameters = []) |
40 | | - { |
41 | | - $this->field = $field; |
42 | | - $this->values = $values; |
43 | | - $this->setParameters($parameters); |
44 | | - } |
45 | | - |
46 | | - /** |
47 | | - * {@inheritdoc} |
48 | | - */ |
49 | | - public function getType() |
50 | | - { |
51 | | - return 'geo_bounding_box'; |
52 | | - } |
53 | | - |
54 | | - /** |
55 | | - * {@inheritdoc} |
56 | | - */ |
57 | | - public function toArray() |
58 | | - { |
59 | | - if (count($this->values) === 2) { |
60 | | - $query = [ |
61 | | - $this->field => [ |
62 | | - 'top_left' => $this->values[0], |
63 | | - 'bottom_right' => $this->values[1], |
64 | | - ], |
65 | | - ]; |
66 | | - } elseif (count($this->values) === 4) { |
67 | | - $query = [ |
68 | | - $this->field => [ |
69 | | - 'top' => $this->values[0], |
70 | | - 'left' => $this->values[1], |
71 | | - 'bottom' => $this->values[2], |
72 | | - 'right' => $this->values[3], |
73 | | - ], |
74 | | - ]; |
75 | | - } else { |
76 | | - throw new \LogicException('Geo Bounding Box filter must have 2 or 4 geo points set.'); |
77 | | - } |
78 | | - |
79 | | - $output = $this->processArray($query); |
80 | | - |
81 | | - return $output; |
82 | | - } |
83 | 28 | } |
0 commit comments