rangeGenerator->generateRange($at); if (null === $range) { return; } ['startDate' => $startDate, 'endDate' => $endDate] = $range; $offset = 0; $batchSize = 10; $calendars = $this->calendarRepository ->findByNotificationAvailable($startDate, $endDate, $batchSize, $offset); do { foreach ($calendars as $calendar) { ++$offset; yield $calendar; } $this->em->clear(); $calendars = $this->calendarRepository ->findByNotificationAvailable($startDate, $endDate, $batchSize, $offset); } while (\count($calendars) === $batchSize); } }