Neos\Media\Domain\Repository\ThumbnailRepository::findUngeneratedIterator PHP Method

findUngeneratedIterator() public method

Find ungenerated objects and return an IterableResult
public findUngeneratedIterator ( ) : Doctrine\ORM\Internal\Hydration\IterableResult
return Doctrine\ORM\Internal\Hydration\IterableResult
    public function findUngeneratedIterator()
    {
        /** @var QueryBuilder $queryBuilder */
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder->select('t')->from($this->getEntityClassName(), 't')->where('t.resource IS NULL AND t.staticResource IS NULL');
        return $queryBuilder->getQuery()->iterate();
    }

Usage Example

 /**
  * Render ungenerated thumbnails
  *
  * Loops over ungenerated thumbnails and renders them. Optional ``limit`` parameter to limit the amount of
  * thumbnails to be rendered to avoid memory exhaustion.
  *
  * @param integer $limit Limit the amount of thumbnails to be rendered to avoid memory exhaustion
  * @return void
  */
 public function renderThumbnailsCommand($limit = null)
 {
     $thumbnailCount = $this->thumbnailRepository->countUngenerated();
     $iterator = $this->thumbnailRepository->findUngeneratedIterator();
     $this->output->progressStart($limit !== null && $thumbnailCount > $limit ? $limit : $thumbnailCount);
     $iteration = 0;
     foreach ($this->thumbnailRepository->iterate($iterator) as $thumbnail) {
         if ($thumbnail->getResource() === null) {
             $this->thumbnailService->refreshThumbnail($thumbnail);
             $this->persistenceManager->persistAll();
         }
         $this->output->progressAdvance(1);
         $iteration++;
         if ($iteration === $limit) {
             break;
         }
     }
 }