@@ -153,6 +153,41 @@ public function initialise($container)
153
153
*
154
154
* @return string
155
155
*/
156
+ protected function getTranslationFieldNameWithParents ($ column )
157
+ {
158
+ $ name = $ column ->getField ();
159
+
160
+ if ($ column ->getIsManualField ()) {
161
+ return $ column ->getField ();
162
+ }
163
+
164
+ if (strpos ($ name , '. ' ) !== false ) {
165
+ $ previousParent = '' ;
166
+
167
+ $ elements = explode ('. ' , $ name );
168
+ while ($ element = array_shift ($ elements )) {
169
+ if (count ($ elements ) > 0 ) {
170
+ $ previousParent .= '_ ' . $ element ;
171
+ }
172
+ }
173
+ } elseif (strpos ($ name , ': ' ) !== false ) {
174
+ $ previousParent = $ this ->getTableAlias ();
175
+ } else {
176
+ return $ this ->getTableAlias ().'. ' .$ name ;
177
+ }
178
+
179
+ $ matches = array ();
180
+ if ($ column ->hasDQLFunction ($ matches )) {
181
+ return $ previousParent .'. ' .$ matches ['field ' ];
182
+ }
183
+
184
+ return $ column ->getField ();
185
+ }
186
+
187
+ /**
188
+ * @param \APY\DataGridBundle\Grid\Column\Column $column
189
+ * @return string
190
+ */
156
191
protected function getFieldName ($ column , $ withAlias = false )
157
192
{
158
193
$ name = $ column ->getField ();
@@ -373,7 +408,11 @@ public function execute($columns, $page = 0, $limit = 0, $maxResults = null, $gr
373
408
374
409
$ isDisjunction = $ column ->getDataJunction () === Column::DATA_DISJUNCTION ;
375
410
376
- $ hasHavingClause = $ column ->hasDQLFunction () || $ column ->getIsAggregate ();
411
+ $ dqlMatches = [];
412
+ $ hasHavingClause = $ column ->hasDQLFunction ($ dqlMatches ) || $ column ->getIsAggregate ();
413
+ if (isset ($ dqlMatches ['function ' ]) && $ dqlMatches ['function ' ] == 'translation_agg ' ){
414
+ $ hasHavingClause = false ;
415
+ }
377
416
378
417
$ sub = $ isDisjunction ? $ this ->query ->expr ()->orx () : ($ hasHavingClause ? $ this ->query ->expr ()->andx () : $ where );
379
418
@@ -384,8 +423,17 @@ public function execute($columns, $page = 0, $limit = 0, $maxResults = null, $gr
384
423
385
424
$ fieldName = $ this ->getFieldName ($ columnForFilter , false );
386
425
$ bindIndexPlaceholder = "? $ bindIndex " ;
387
- if (in_array ($ filter ->getOperator (), [Column::OPERATOR_LIKE , Column::OPERATOR_RLIKE , Column::OPERATOR_LLIKE , Column::OPERATOR_NLIKE ])) {
388
- $ fieldName = "LOWER( $ fieldName) " ;
426
+
427
+ if ( in_array ($ filter ->getOperator (), array (Column::OPERATOR_LIKE ,Column::OPERATOR_RLIKE ,Column::OPERATOR_LLIKE ,Column::OPERATOR_NLIKE ,))){
428
+ if (isset ($ dqlMatches ['function ' ]) && $ dqlMatches ['function ' ] == 'translation_agg ' ){
429
+ $ translationFieldName = $ this ->getTranslationFieldNameWithParents ($ columnForFilter );
430
+ $ fieldName = "LOWER( " .$ translationFieldName .") " ;
431
+ }elseif (isset ($ dqlMatches ['function ' ]) && $ dqlMatches ['function ' ] == 'role_agg ' ){
432
+ $ translationFieldName = $ this ->getTranslationFieldNameWithParents ($ columnForFilter );
433
+ $ fieldName = "LOWER( " .$ translationFieldName .") " ;
434
+ }else {
435
+ $ fieldName = "LOWER( $ fieldName) " ;
436
+ }
389
437
$ bindIndexPlaceholder = "LOWER( $ bindIndexPlaceholder) " ;
390
438
}
391
439
0 commit comments