Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Batch.php
Go to the documentation of this file.
1 <?php
7 
8 class Batch
9 {
15  public function getItems(\Traversable $documents, $size)
16  {
17  $i = 0;
18  $batch = [];
19 
20  foreach ($documents as $documentName => $documentValue) {
21  $batch[$documentName] = $documentValue;
22  if (++$i == $size) {
23  yield $batch;
24  $i = 0;
25  $batch = [];
26  }
27  }
28  if (count($batch) > 0) {
29  yield $batch;
30  }
31  }
32 }
getItems(\Traversable $documents, $size)
Definition: Batch.php:15
$i
Definition: gallery.phtml:31