Neos\Media\Domain\Repository\AssetRepository::countAll PHP Method

countAll() public method

public countAll ( ) : integer
return integer
    public function countAll()
    {
        $rsm = new ResultSetMapping();
        $rsm->addScalarResult('c', 'c');
        $queryString = "SELECT count(persistence_object_identifier) c FROM neos_media_domain_model_asset WHERE dtype != 'neos_media_imagevariant'";
        $query = $this->entityManager->createNativeQuery($queryString, $rsm);
        return $query->getSingleScalarResult();
    }

Usage Example

 /**
  * Create thumbnails
  *
  * Creates thumbnail images based on the configured thumbnail presets. Optional ``preset`` parameter to only create
  * thumbnails for a specific thumbnail preset configuration.
  *
  * Additionally accepts a ``async`` parameter determining if the created thumbnails are generated when created.
  *
  * @param string $preset Preset name, if not provided thumbnails are created for all presets
  * @param boolean $async Asynchronous generation, if not provided the setting ``Neos.Media.asyncThumbnails`` is used
  * @return void
  */
 public function createThumbnailsCommand($preset = null, $async = null)
 {
     $async = $async !== null ? $async : $this->asyncThumbnails;
     $presets = $preset !== null ? [$preset] : array_keys($this->thumbnailService->getPresets());
     $presetThumbnailConfigurations = [];
     foreach ($presets as $preset) {
         $presetThumbnailConfigurations[] = $this->thumbnailService->getThumbnailConfigurationForPreset($preset, $async);
     }
     $iterator = $this->assetRepository->findAllIterator();
     $imageCount = $this->assetRepository->countAll();
     $this->output->progressStart($imageCount * count($presetThumbnailConfigurations));
     foreach ($this->assetRepository->iterate($iterator) as $image) {
         foreach ($presetThumbnailConfigurations as $presetThumbnailConfiguration) {
             $this->thumbnailService->getThumbnail($image, $presetThumbnailConfiguration);
             $this->persistenceManager->persistAll();
             $this->output->progressAdvance(1);
         }
     }
 }
All Usage Examples Of Neos\Media\Domain\Repository\AssetRepository::countAll