From e707b178245a85ddf4e44edd65f99db04763606e Mon Sep 17 00:00:00 2001 From: Ishiki Date: Tue, 24 Mar 2020 21:11:37 +0200 Subject: [PATCH] ArraySorterExtension DateTime support We have array of objects, objects implements ArrayAccess, everything works fine except sorting by DateTime does not work. I dunno if this is the right solution, but if someone has this issue, you can extend this extension and add this. Ofc by oro logic, array should be array, but in our project we use models in some places and we need datagrid for that. --- .../DataGridBundle/Extension/Sorter/ArraySorterExtension.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Oro/Bundle/DataGridBundle/Extension/Sorter/ArraySorterExtension.php b/src/Oro/Bundle/DataGridBundle/Extension/Sorter/ArraySorterExtension.php index eaff4653190..01ba6739f56 100644 --- a/src/Oro/Bundle/DataGridBundle/Extension/Sorter/ArraySorterExtension.php +++ b/src/Oro/Bundle/DataGridBundle/Extension/Sorter/ArraySorterExtension.php @@ -73,6 +73,10 @@ function ($currentRow, $nextRow) use ($sortingKey, $direction) { */ protected function safeStringConvert($value) { + if ($value instanceof \DateTime) { + $value = $value->getTimestamp(); + } + return iconv('utf-8', 'ascii//TRANSLIT', strtolower((string)$value)); } }