@@ -35,8 +35,9 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
35
35
$ table = $ cObj ->getCurrentTable ();
36
36
$ uid = $ cObj ->data ['uid ' ];
37
37
$ field = $ processorConfiguration ['field ' ];
38
+ $ sorting = $ processorConfiguration ['mm_sorting_field ' ] ?? '' ;
38
39
39
- $ relations = $ this ->getRelation ($ cObj , $ table , $ field , $ uid );
40
+ $ relations = $ this ->getRelation ($ cObj , $ table , $ field , $ uid, $ sorting );
40
41
$ request = $ cObj ->getRequest ();
41
42
$ processedRecordVariables = [];
42
43
@@ -58,7 +59,7 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
58
59
/**
59
60
* @return list<array<string, string|int|float|bool>>
60
61
*/
61
- public function getRelation (ContentObjectRenderer $ cObj , string $ table , string $ field , int $ uid ): array
62
+ public function getRelation (ContentObjectRenderer $ cObj , string $ table , string $ field , int $ uid, string $ sorting ): array
62
63
{
63
64
$ tcaConfig = $ GLOBALS ['TCA ' ][$ table ]['columns ' ][$ field ]['config ' ] ?? throw new RuntimeException (
64
65
'TCA config for ' . $ table . '. ' . $ field . ' not found '
@@ -101,7 +102,9 @@ public function getRelation(ContentObjectRenderer $cObj, string $table, string $
101
102
->from ($ foreignTable , 'relation ' )
102
103
->join ('relation ' , $ mmTable , 'mm ' , $ queryBuilder ->expr ()->eq ('relation.uid ' , 'mm. ' . $ otherField ))
103
104
->where ($ queryBuilder ->expr ()->eq ('mm. ' . $ selfField , $ uid ));
104
-
105
+ if ($ sorting ) {
106
+ $ queryBuilder ->orderBy ($ sorting );
107
+ }
105
108
106
109
$ transOrigPointerField = $ GLOBALS ['TCA ' ][$ foreignTable ]['ctrl ' ]['transOrigPointerField ' ] ?? null ;
107
110
if ($ transOrigPointerField ) {
0 commit comments