/** * @NoAdminRequired * * Returns a list of all media files available to the authenticated user * * * Authentication can be via a login/password or a token/(password) * * For private galleries, it returns all media files, with the full path from the root * folder For public galleries, the path starts from the folder the link gives access to * (virtual root) * * An exception is only caught in case something really wrong happens. As we don't test * files before including them in the list, we may return some bad apples * * @param string $location a path representing the current album in the app * @param array $features the list of supported features * @param string $etag the last known etag in the client * @param array $mediatypes the list of supported media types * * @return array <string,array<string,string|int>>|Http\JSONResponse */ private function getFiles($location, $features, $etag, $mediatypes) { $files = []; /** @var Folder $folderNode */ list($folderPathFromRoot, $folderNode, $locationHasChanged) = $this->searchFolderService->getCurrentFolder(rawurldecode($location), $features); $albumInfo = $this->configService->getAlbumInfo($folderNode, $folderPathFromRoot, $features); if ($albumInfo['etag'] !== $etag) { $files = $this->searchMediaService->getMediaFiles($folderNode, $mediatypes, $features); $files = $this->fixPaths($files, $folderPathFromRoot); } return $this->formatResults($files, $albumInfo, $locationHasChanged); }
/** * Mocks SearchFolderService->getCurrentFolder * * @param $location * @param $folderPathFromRoot * @param $features * @param $locationHasChanged * @param $folder */ private function mockGetCurrentFolder($location, $folderPathFromRoot, $features, $locationHasChanged, $folder) { $answer = [$folderPathFromRoot, $folder, $locationHasChanged]; $this->searchFolderService->expects($this->once())->method('getCurrentFolder')->with($location, $features)->willReturn($answer); }