@@ -18,7 +18,7 @@ class QueryObjectDataSource implements IDataSource
1818 /** @var \Doctrine\ORM\EntityRepository */
1919 protected $ repo ;
2020
21- /** @var \ADT\DoctrineComponents\QueryObject|IQueryObject */
21+ /** @var \ADT\DoctrineComponents\QueryObject */
2222 protected $ queryObject ;
2323
2424 /** @var callable */
@@ -39,15 +39,10 @@ class QueryObjectDataSource implements IDataSource
3939 /**
4040 * QueryObjectDataSource constructor.
4141 * @param \ADT\DoctrineComponents\QueryObject $queryObject
42- * @param \Doctrine\ORM\EntityRepository|null $repo
4342 * @throws \Exception
4443 */
45- public function __construct (\ADT \DoctrineComponents \QueryObject $ queryObject, \ Doctrine \ ORM \ EntityRepository $ repo = null )
44+ public function __construct (\ADT \DoctrineComponents \QueryObject $ queryObject )
4645 {
47- if (!$ repo && (!$ queryObject instanceof IQueryObject)) {
48- throw new \Exception ('"repo" must be set or "queryObject" has to implement IQueryObject interface. ' );
49- }
50-
5146 $ this ->queryObject = $ queryObject ;
5247 $ this ->repo = $ repo ?: $ queryObject ->getEntityManager ();
5348 }
@@ -147,7 +142,7 @@ public function filter(array $filters): void
147142 if ($ filter ->getConditionCallback ()) {
148143 call_user_func ($ filter ->getConditionCallback (), $ this ->queryObject , $ filter ->getValue ());
149144 }
150- elseif (!$ filter instanceof FilterDateRange && $ this -> queryObject instanceof IQueryObject ) {
145+ elseif (!$ filter instanceof FilterDateRange) {
151146 $ this ->queryObject ->searchIn (
152147 $ filter instanceof OneColumnFilter ? $ filter ->getColumn () : $ filter ->getKey (),
153148 $ filter ->getValue (),
@@ -205,21 +200,7 @@ public function sort(\Ublaboo\DataGrid\Utils\Sorting $sorting): IDataSource {
205200 );
206201
207202 } else {
208-
209- $ sort = $ sorting ->getSort ();
210-
211- if (!empty ($ sort ) && ($ this ->queryObject instanceof IQueryObject)) {
212- $ isFirst = true ;
213- foreach ($ sort as $ column => $ order ) {
214- if ($ isFirst ) {
215- $ this ->queryObject ->orderBy ($ column , $ order );
216- }
217- else {
218- $ this ->queryObject ->addOrderBy ($ column , $ order );
219- }
220- $ isFirst = false ;
221- }
222- }
203+ $ this ->queryObject ->orderBy ($ sorting ->getSort ());
223204 }
224205
225206 if (is_callable ($ this ->sortCallback )) {
0 commit comments