|
17 | 17 | use Fau\DegreeProgram\Common\Application\Filter\SubjectGroupFilter;
|
18 | 18 | use Fau\DegreeProgram\Common\Application\Filter\TeachingLanguageFilter;
|
19 | 19 | use Fau\DegreeProgram\Common\Application\Repository\CollectionCriteria;
|
20 |
| -use Fau\DegreeProgram\Common\Domain\CampoKeys; |
21 | 20 | use Fau\DegreeProgram\Common\Domain\DegreeProgram;
|
22 | 21 | use Fau\DegreeProgram\Common\Domain\MultilingualString;
|
23 | 22 | use Fau\DegreeProgram\Common\Infrastructure\Content\PostType\DegreeProgramPostType;
|
24 | 23 | use Fau\DegreeProgram\Common\Infrastructure\Content\Taxonomy\BachelorOrTeachingDegreeAdmissionRequirementTaxonomy;
|
25 | 24 | use Fau\DegreeProgram\Common\Infrastructure\Content\Taxonomy\MasterDegreeAdmissionRequirementTaxonomy;
|
26 | 25 | use Fau\DegreeProgram\Common\Infrastructure\Content\Taxonomy\TaxonomiesList;
|
27 |
| -use Fau\DegreeProgram\Common\Infrastructure\Content\Taxonomy\TeachingDegreeHigherSemesterAdmissionRequirementTaxonomy; |
28 |
| -use RuntimeException; |
29 | 26 | use WP_Term;
|
30 | 27 |
|
31 | 28 | /**
|
@@ -270,31 +267,28 @@ private function applyTaxonomyFilter(Filter $filter, WpQueryArgs $queryArgs): Wp
|
270 | 267 |
|
271 | 268 | private function applySearchFilter(SearchKeywordFilter $filter, WpQueryArgs $queryArgs, ?string $languageCode = null): WpQueryArgs
|
272 | 269 | {
|
273 |
| - if (!$languageCode) { |
274 |
| - return $queryArgs->withMetaQueryItem( |
275 |
| - [ |
276 |
| - 'relation' => 'OR', |
277 |
| - [ |
278 |
| - 'key' => 'fau_degree_program_searchable_content_' . MultilingualString::EN, |
279 |
| - 'value' => $filter->value(), |
280 |
| - 'compare' => 'LIKE', |
281 |
| - ], |
282 |
| - [ |
283 |
| - 'key' => 'fau_degree_program_searchable_content_' . MultilingualString::DE, |
284 |
| - 'value' => $filter->value(), |
285 |
| - 'compare' => 'LIKE', |
286 |
| - ], |
287 |
| - ] |
| 270 | + $keywords = array_filter(array_map('trim', explode(' ', $filter->value()))); |
| 271 | + $metaKeyPrefix = 'fau_degree_program_searchable_content_'; |
| 272 | + $metaKeys = is_string($languageCode) && $languageCode |
| 273 | + ? [$metaKeyPrefix . $languageCode] |
| 274 | + : [$metaKeyPrefix . MultilingualString::EN, $metaKeyPrefix . MultilingualString::DE]; |
| 275 | + |
| 276 | + $metaQuery = array_reduce($keywords, static function (array $metaQuery, string $keyword) use ($metaKeys): array { |
| 277 | + $keywordConditions = array_map( |
| 278 | + static fn($key) => [ |
| 279 | + 'key' => $key, |
| 280 | + 'value' => $keyword, |
| 281 | + 'compare' => 'LIKE', |
| 282 | + ], |
| 283 | + $metaKeys |
288 | 284 | );
|
289 |
| - } |
290 | 285 |
|
291 |
| - return $queryArgs->withMetaQueryItem( |
292 |
| - [ |
293 |
| - 'key' => 'fau_degree_program_searchable_content_' . $languageCode, |
294 |
| - 'value' => $filter->value(), |
295 |
| - 'compare' => 'LIKE', |
296 |
| - ] |
297 |
| - ); |
| 286 | + $metaQuery[] = ['relation' => 'OR'] + $keywordConditions; |
| 287 | + |
| 288 | + return $metaQuery; |
| 289 | + }, ['relation' => 'AND']); |
| 290 | + |
| 291 | + return $queryArgs->withMetaQueryItem($metaQuery); |
298 | 292 | }
|
299 | 293 |
|
300 | 294 | private function currentTerm(CollectionCriteria $criteria): ?WP_Term
|
|
0 commit comments