Hi all,
I’m trying to implement a preview feature for detail views of an Extbase model.
Using $GLOBALS['BE_USER']->isAdmin();
I’m checking if the user is an admin. An admin should be able to view hidden records in the frontend.
I’ve tried to modify the query settings in my repository, but this doesn’t seem to work. Even as an admin, I get 404’s for hidden records in the frontend. I’ve looked through the source code of georgringer/news
and I’m pretty sure I didn’t miss anything.
class ReferenceProjectRepository extends Repository {
public function findByUid($uid, $includeHidden = true) {
$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage(false);
$query->getQuerySettings()->setRespectSysLanguage(false);
if ($includeHidden) {
$query->getQuerySettings()->setIgnoreEnableFields(true);
}
return $query->matching(
$query->logicalAnd(
$query->equals('uid', $uid),
$query->equals('deleted', 0)
)
)->execute()->getFirst();
}
}
public function detailAction(string $id = null): ResponseInterface {
$isAdmin = $GLOBALS['BE_USER']->isAdmin();
if (is_string($id)) {
$reference = $this->referenceProjectRepository->findByUid($id, $isAdmin);
}
$this->view->assignMultiple([
'reference' => $reference ?? null,
]);
return $this->htmlResponse();
}
Any help is much appreciated.