Skip to content

Commit 58403bc

Browse files
committed
move setting of pageModel further up
1 parent e476086 commit 58403bc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Controller/FilesController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ public function fileAction(Request $request, string $file): BinaryFileResponse
5454
throw new PageNotFoundException();
5555
}
5656

57+
// Set the root page for the domain as the pageModel attribute
58+
$root = PageModel::findFirstPublishedRootByHostAndLanguage($request->getHost(), $request->getLocale());
59+
60+
if (null !== $root) {
61+
$request->attributes->set('pageModel', $root);
62+
}
63+
5764
// Check whether the file exists
5865
if (!is_file(Path::join($this->rootDir, $file))) {
5966
throw new PageNotFoundException();
@@ -120,13 +127,6 @@ public function fileAction(Request $request, string $file): BinaryFileResponse
120127

121128
// Deny access
122129
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-
130130
// If a user is authenticated or the 401 exception does not exist, throw 403 exception
131131
if ($this->security->isGranted('ROLE_MEMBER')) {
132132
throw new AccessDeniedException();

0 commit comments

Comments
 (0)