Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
25 | public function wrapIterable(iterable $resultSet, int $batchSize): iterable |
||
26 | { |
||
27 | $iteration = 0; |
||
28 | |||
29 | $this->em->beginTransaction(); |
||
30 | |||
31 | try { |
||
32 | foreach ($resultSet as $key => $value) { |
||
33 | $iteration++; |
||
34 | yield $key => $value; |
||
35 | $this->flushAndClearBatch($iteration, $batchSize); |
||
36 | } |
||
37 | } catch (Throwable $e) { |
||
38 | $this->em->rollback(); |
||
39 | |||
40 | throw $e; |
||
41 | } |
||
42 | |||
43 | $this->flushAndClearEntityManager(); |
||
44 | $this->em->commit(); |
||
45 | } |
||
62 |