Skip to content

Commit 7ac2cc1

Browse files
committed
Merge branch '4.0.x'
2 parents 22fcedb + 46ab2f5 commit 7ac2cc1

6 files changed

+53
-2
lines changed

CHANGELOG-4.0.md

+3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ in 4.0 versions.
88

99
* Add `ruflin/Elastica` 3.x support.
1010
* Add new repository manager.
11+
* Add support for `DateTimeInterface` in `ModelToElasticaAutoTransformer`.
12+
* Add support for suggesters.
1113
* Dropped PHP 5.3 and 5.4 support.
1214
* Removed Symfony < 2.7 support.
1315
* [BC break] Allow additional parameters to `AbstractProvider::queryBuilder`.
16+
* [BC break] Added `PaginatorAdapterInterface::getSuggests`.
1417
* [BC break] Removed faceted search support.
1518
* [BC break] Removed `AbstractProvider::isObjectIndexable`.
1619
* [BC break] Removed `AbstractProvider::getMemoryUsage`.

Paginator/FantaPaginatorAdapter.php

+12
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ public function getAggregations()
4747
return $this->adapter->getAggregations();
4848
}
4949

50+
/**
51+
* Returns Suggestions.
52+
*
53+
* @return mixed
54+
*
55+
* @api
56+
*/
57+
public function getSuggests()
58+
{
59+
return $this->adapter->getSuggests();
60+
}
61+
5062
/**
5163
* Returns a slice of the results.
5264
*

Paginator/PaginatorAdapterInterface.php

+7
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,11 @@ public function getResults($offset, $length);
3636
* @return mixed
3737
*/
3838
public function getAggregations();
39+
40+
/**
41+
* Returns Suggests.
42+
*
43+
* @return mixed
44+
*/
45+
public function getSuggests();
3946
}

Paginator/RawPaginatorAdapter.php

+18-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class RawPaginatorAdapter implements PaginatorAdapterInterface
4646
*/
4747
private $aggregations;
4848

49+
/**
50+
* @var array for the suggesters
51+
*/
52+
private $suggests;
53+
4954
/**
5055
* @see PaginatorAdapterInterface::__construct
5156
*
@@ -92,8 +97,8 @@ protected function getElasticaResults($offset, $itemCountPerPage)
9297

9398
$resultSet = $this->searchable->search($query, $this->options);
9499
$this->totalHits = $resultSet->getTotalHits();
95-
96100
$this->aggregations = $resultSet->getAggregations();
101+
$this->suggests = $resultSet->getSuggests();
97102

98103
return $resultSet;
99104
}
@@ -138,6 +143,18 @@ public function getAggregations()
138143
return $this->aggregations;
139144
}
140145

146+
/**
147+
* {@inheritdoc}
148+
*/
149+
public function getSuggests()
150+
{
151+
if (!isset($this->suggests)) {
152+
$this->suggests = $this->searchable->search($this->query)->getSuggests();
153+
}
154+
155+
return $this->suggests;
156+
}
157+
141158
/**
142159
* Returns the Query.
143160
*

Paginator/RawPartialResults.php

+12
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,16 @@ public function getAggregations()
5858

5959
return;
6060
}
61+
62+
/**
63+
* {@inheritDoc}
64+
*/
65+
public function getSuggests()
66+
{
67+
if ($this->resultSet->hasSuggests()) {
68+
return $this->resultSet->getSuggests();
69+
}
70+
71+
return;
72+
}
6173
}

Transformer/ModelToElasticaAutoTransformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ protected function transformNested($objects, array $fields)
119119
protected function normalizeValue($value)
120120
{
121121
$normalizeValue = function (&$v) {
122-
if ($v instanceof \DateTime) {
122+
if ($v instanceof \DateTimeInterface) {
123123
$v = $v->format('c');
124124
} elseif (!is_scalar($v) && !is_null($v)) {
125125
$v = (string) $v;

0 commit comments

Comments
 (0)