/**
  * @param Request $request
  *
  * @Rest\Pagination(default_count=25, max_count=100)
  */
 public function getCollectionAction(Request $request, $start, $count)
 {
     $queryParams = $request->query->all();
     $mediaFolderUid = $request->get('mediaFolder_uid', null);
     $usePagination = $request->get("usePagination", false);
     $contentType = $request->get('contentType', null);
     if (null === $mediaFolderUid) {
         $mediaFolder = $this->getMediaFolderRepository()->getRoot();
     } else {
         $mediaFolder = $this->getMediaFolderRepository()->find($mediaFolderUid);
     }
     if (null === $mediaFolder) {
         throw new NotFoundHttpException('Cannot find a media folder');
     }
     if (null !== $contentType) {
         try {
             $queryParams['contentType'] = AbstractContent::getClassnameByContentType($contentType);
         } catch (InvalidContentTypeException $e) {
             throw new NotFoundHttpException(sprintf('Provided content type (:%s) is invalid.', $queryParams['contentType']));
         }
     }
     $paging = ['start' => $start, 'limit' => $count];
     $paginator = $this->getMediaRepository()->getMedias($mediaFolder, $queryParams, '_modified', 'desc', $paging);
     $resultsIter = $paginator->getIterator();
     $results = [];
     while ($resultsIter->valid()) {
         $results[] = $resultsIter->current();
         $resultsIter->next();
     }
     $pager = $usePagination ? $paginator : null;
     return $this->addRangeToContent($this->createJsonResponse($this->mediaToJson($results)), $pager, $start, count($results));
 }
 private function getClassicCollection(Request $request, $mediafolder, $start, $count)
 {
     $params = $request->query->all();
     $contentType = $request->get('contentType', null);
     if (null !== $contentType) {
         try {
             $params['contentType'] = AbstractContent::getClassnameByContentType($contentType);
         } catch (InvalidContentTypeException $e) {
             throw new NotFoundHttpException(sprintf('Provided content type (:%s) is invalid.', $params['contentType']));
         }
     }
     return $this->getMediaRepository()->getMedias($mediafolder, $params, '_modified', 'desc', ['start' => $start, 'limit' => $count]);
 }