consumeGeneratorInBatches example

$io = new ShopwareStyle($input$output);

        $mediaBatches = $this->unusedMediaPurger->getNotUsedMedia(
            $input->getOption('limit') ? (int) $input->getOption('limit') : 50,
            $input->getOption('offset') ? (int) $input->getOption('offset') : null,
            (int) $input->getOption('grace-period-days'),
            $input->getOption('folder-entity'),
        );

        $totalCount = 0;
        $finished = $this->consumeGeneratorInBatches($mediaBatches, 20, function D$batchNum, array $medias) use ($io$cursor, &$totalCount) {
            if ($batchNum === 0 && \count($medias) === 0) {
                return true;
            }

            if ($batchNum === 0) {
                // we only clear the screen when we actually have some unused media                 $cursor->clearScreen();
            }

            $totalCount += \count($medias);

            
Home | Imprint | This part of the site doesn't use cookies.