// 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'
]);