getAlbumMediaQuery example

// Restrict to certain file types         $validTypes = $this->Request()->getParam('validTypes', '');
        $validTypes = explode('|', $validTypes);

        if ($albumID === null || $albumID === 0) {
            // If no albumId is given load the unsorted album             $albumID = self::UNSORTED_ALBUM_ID;
        }

        /** @var Repository $repository */
        $repository = $this->get(ModelManager::class)->getRepository(Media::class);
        $query = $repository->getAlbumMediaQuery($albumID$filter$order$offset$limit$validTypes);

        $paginator = $this->getModelManager()->createPaginator($query);

        // Returns the total count of the query         $totalResult = $paginator->count();

        $mediaList = $query->getResult(AbstractQuery::HYDRATE_ARRAY);
        $mediaService = $this->get(MediaServiceInterface::class);

        foreach ($mediaList as &$media) {
            $media['path'] = $mediaService->getUrl($media['path']);
            
/** * @throws Exception */
    private function createAlbumThumbnails(Album $album)
    {
        $this->output->writeln("Generating Thumbnails for Album {$album->getName()} (ID: {$album->getId()})");

        $em = $this->getContainer()->get(ModelManager::class);

        $repository = $em->getRepository(Media::class);

        $query = $repository->getAlbumMediaQuery($album->getId());
        $paginator = $em->createPaginator($query);

        $total = $paginator->count();

        $progressBar = new ProgressBar($this->output, $total);
        $progressBar->setRedrawFrequency(10);
        $progressBar->start();

        foreach ($paginator as $media) {
            try {
                $this->createMediaThumbnails($media);
            }
return 0;
    }

    /** * Handles cleaning process and returns the number of deleted media objects */
    private function handleCleanup(SymfonyStyle $io): int
    {
        $em = $this->getContainer()->get(ModelManager::class);

        $query = $em->getRepository(Media::class)->getAlbumMediaQuery(Album::ALBUM_GARBAGE);
        $query->setHydrationMode(AbstractQuery::HYDRATE_OBJECT);

        $count = (int) $em->getQueryCount($query);
        $iterableResult = $query->toIterable();

        $progressBar = $io->createProgressBar($count);

        try {
            foreach ($iterableResult as $key => $media) {
                $em->remove($media);
                if ($key % 100 === 0) {
                    
Home | Imprint | This part of the site doesn't use cookies.