Skip to content

Commit 351a751

Browse files
committed
Add AbstractSearchOperator::prepareDocuments for MoreLikeThis
1 parent 393b60c commit 351a751

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Search/AbstractSearchOperator.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ protected function prepareFieldPath(string|array $field): string|array
8585
return $this->persister->prepareFieldName($field);
8686
}
8787

88+
/**
89+
* @param list<array<string, mixed>|object> $documents
90+
*
91+
* @return list<array<string, mixed>|object>
92+
*/
93+
protected function prepareDocuments(array $documents): array
94+
{
95+
return array_map($this->persister->prepareQueryOrNewObj(...), $documents);
96+
}
97+
8898
protected function getDocumentPersister(): DocumentPersister
8999
{
90100
return $this->persister;

lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Search/MoreLikeThis.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Doctrine\ODM\MongoDB\Aggregation\Stage\Search;
88
use Doctrine\ODM\MongoDB\Persisters\DocumentPersister;
99

10-
use function array_map;
1110
use function array_values;
1211

1312
/**
@@ -36,7 +35,7 @@ public function getOperatorName(): string
3635
public function getOperatorParams(): object
3736
{
3837
return (object) [
39-
'like' => array_map($this->getDocumentPersister()->prepareQueryOrNewObj(...), $this->like),
38+
'like' => $this->prepareDocuments($this->like),
4039
];
4140
}
4241
}

0 commit comments

Comments
 (0)