Skip to content

Commit

Permalink
move setting of pageModel further up
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzmg committed Jun 9, 2022
1 parent e476086 commit 58403bc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Controller/FilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ public function fileAction(Request $request, string $file): BinaryFileResponse
throw new PageNotFoundException();
}

// Set the root page for the domain as the pageModel attribute
$root = PageModel::findFirstPublishedRootByHostAndLanguage($request->getHost(), $request->getLocale());

if (null !== $root) {
$request->attributes->set('pageModel', $root);
}

// Check whether the file exists
if (!is_file(Path::join($this->rootDir, $file))) {
throw new PageNotFoundException();
Expand Down Expand Up @@ -120,13 +127,6 @@ public function fileAction(Request $request, string $file): BinaryFileResponse

// Deny access
if (!$allowAccess) {
// Set the root page for the domain as the pageModel attribute
$root = PageModel::findFirstPublishedRootByHostAndLanguage($request->getHost(), $request->getLocale());

if (null !== $root) {
$request->attributes->set('pageModel', $root);
}

// If a user is authenticated or the 401 exception does not exist, throw 403 exception
if ($this->security->isGranted('ROLE_MEMBER')) {
throw new AccessDeniedException();
Expand Down

0 comments on commit 58403bc

Please sign in to comment.