| Conditions | 5 |
| Paths | 4 |
| Total Lines | 25 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 22 | public function doGetPaginatedResults( |
||
| 23 | QueryBuilder $qb, |
||
| 24 | array $filters = [], |
||
| 25 | array $sorting = [], |
||
| 26 | int $page = 1, |
||
| 27 | int $pageSize = 25 |
||
| 28 | ): PaginatorInterface { |
||
| 29 | $alias = $qb->getRootAliases()[0]; |
||
| 30 | // add clauses for where |
||
| 31 | if (count($filters) > 0) { |
||
| 32 | $i = 1; |
||
| 33 | foreach ($filters as $w_key => $w_value) { |
||
| 34 | $qb->andWhere($qb->expr()->eq($alias . '.' . $w_key, '?' . $i)) |
||
| 35 | ->setParameter($i, $w_value); |
||
| 36 | $i++; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | // add clause for ordering |
||
| 40 | if (count($sorting) > 0) { |
||
| 41 | foreach ($sorting as $sort => $sortdir) { |
||
| 42 | $qb->addOrderBy($alias . '.' . $sort, $sortdir); |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | return (new Paginator($qb, $pageSize))->paginate($page); |
||
| 47 | } |
||
| 49 |