Conditions | 3 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
31 | public function getStockMovements(): Generator |
||
32 | { |
||
33 | $qb = $this->repository->createQueryBuilder('o'); |
||
34 | |||
35 | foreach ($this->filters as $filter) { |
||
36 | $filter->filter($qb); |
||
37 | } |
||
38 | |||
39 | // Use output walkers option in DoctrineORMAdapter should be false as it affects performance greatly. (see https://github.com/Sylius/Sylius/issues/3775) |
||
40 | $paginator = new Pagerfanta(new DoctrineORMAdapter($qb, false, false)); |
||
41 | $paginator->setNormalizeOutOfRangePages(true); |
||
42 | |||
43 | $paginator->setMaxPerPage(100); |
||
44 | $pages = $paginator->getNbPages(); |
||
45 | |||
46 | for ($page = 1; $page <= $pages; ++$page) { |
||
47 | $paginator->setCurrentPage($page); |
||
48 | |||
49 | yield from $paginator->getCurrentPageResults(); |
||
50 | } |
||
53 |