Added Downloads to search index.
This commit is contained in:
1 parent
710f95794c
commit
cf7a04ea15
6 files changed
+295
-22
No files matched your search
@@ -51,6 +51,39 @@ final class DownloadFileResolver
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same contract as resolve(), addressed by the record slug - the pretty
|
||||
* /download/<slug> route. Slugs are unique (eval: uniqueInPid).
|
||||
*
|
||||
* @return array{path: string, name: string, size: int, mimeType: string}|null
|
||||
*/
|
||||
public static function resolveBySlug(string $slug): ?array
|
||||
{
|
||||
if ($slug === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$qb = GeneralUtility::makeInstance(ConnectionPool::class)
|
||||
->getQueryBuilderForTable('tx_vitec_domain_model_download');
|
||||
$uid = $qb
|
||||
->select('uid')
|
||||
->from('tx_vitec_domain_model_download')
|
||||
->where(
|
||||
$qb->expr()->eq('slug', $qb->createNamedParameter($slug, ParameterType::STRING)),
|
||||
$qb->expr()->eq('deleted', 0),
|
||||
$qb->expr()->eq('hidden', 0)
|
||||
)
|
||||
->setMaxResults(1)
|
||||
->executeQuery()
|
||||
->fetchOne();
|
||||
|
||||
return $uid ? self::resolve((int)$uid) : null;
|
||||
} catch (\Throwable $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** @return array<string,mixed>|null */
|
||||
private static function loadDownload(int $uid): ?array
|
||||
{
|
||||
@@ -62,7 +95,10 @@ final class DownloadFileResolver
|
||||
->where(
|
||||
$qb->expr()->eq('uid', $qb->createNamedParameter($uid, ParameterType::INTEGER)),
|
||||
$qb->expr()->eq('deleted', 0),
|
||||
$qb->expr()->eq('hidden', 0)
|
||||
$qb->expr()->eq('hidden', 0),
|
||||
// private downloads are never served publicly - the caller
|
||||
// cannot distinguish this from a missing file, by design
|
||||
$qb->expr()->eq('private_download', 0)
|
||||
)
|
||||
->setMaxResults(1)
|
||||
->executeQuery()
|
||||
|
||||
Reference in new issue
Block a user