Skip to content

Commit b6f8d61

Browse files
pavlosdanfubhy
authored andcommitted
Add language support to sorts (#747)
1 parent bfec5c2 commit b6f8d61

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

modules/graphql_core/src/Plugin/GraphQL/Fields/EntityQuery/EntityQuery.php

100755100644
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ protected function applySort(QueryInterface $query, $sort) {
255255
if (!empty($sort) && is_array($sort)) {
256256
foreach ($sort as $item) {
257257
$direction = !empty($item['direction']) ? $item['direction'] : 'DESC';
258-
$query->sort($item['field'], $direction);
258+
$language = !empty($item['language']) ? $item['language'] : null;
259+
$query->sort($item['field'], $direction, $language);
259260
}
260261
}
261262

@@ -282,7 +283,7 @@ protected function applyFilter(QueryInterface $query, $filter) {
282283
$filterConditions = $this->buildFilterConditions($query, $filter);
283284
if (count($filterConditions->conditions())) {
284285
$query->condition($filterConditions);
285-
}
286+
}
286287
}
287288

288289
return $query;
@@ -313,7 +314,7 @@ protected function buildFilterConditions(QueryInterface $query, array $filter) {
313314
if (isset($condition['enabled']) && empty($condition['enabled'])) {
314315
continue;
315316
}
316-
317+
317318
$field = $condition['field'];
318319
$value = !empty($condition['value']) ? $condition['value'] : NULL;
319320
$operator = !empty($condition['operator']) ? $condition['operator'] : NULL;
@@ -364,7 +365,7 @@ protected function buildFilterConditions(QueryInterface $query, array $filter) {
364365
$filterConditions = $this->buildFilterConditions($query, $args);
365366
if (count($filterConditions->conditions())) {
366367
$group->condition($filterConditions);
367-
}
368+
}
368369
}
369370

370371
return $group;

modules/graphql_core/src/Plugin/GraphQL/InputTypes/EntityQuery/EntityQuerySortInput.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
* "direction" = {
1414
* "type" = "SortOrder",
1515
* "default" = "DESC"
16-
* }
16+
* },
17+
* "language" = "LanguageId"
1718
* }
1819
* )
1920
*/

0 commit comments

Comments
 (0)