Skip to content

Commit e476086

Browse files
committed
revert root page retrieval
1 parent cbd6e8a commit e476086

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Controller/FilesController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Contao\Dbafs;
2121
use Contao\FilesModel;
2222
use Contao\FrontendUser;
23+
use Contao\PageModel;
2324
use Doctrine\DBAL\Connection;
2425
use Symfony\Component\HttpFoundation\BinaryFileResponse;
2526
use Symfony\Component\HttpFoundation\Request;
@@ -119,6 +120,13 @@ public function fileAction(Request $request, string $file): BinaryFileResponse
119120

120121
// Deny access
121122
if (!$allowAccess) {
123+
// Set the root page for the domain as the pageModel attribute
124+
$root = PageModel::findFirstPublishedRootByHostAndLanguage($request->getHost(), $request->getLocale());
125+
126+
if (null !== $root) {
127+
$request->attributes->set('pageModel', $root);
128+
}
129+
122130
// If a user is authenticated or the 401 exception does not exist, throw 403 exception
123131
if ($this->security->isGranted('ROLE_MEMBER')) {
124132
throw new AccessDeniedException();

0 commit comments

Comments
 (0)