Skip to content

Commit

Permalink
Use createNotFoundException method instead of directly creating NotFo…
Browse files Browse the repository at this point in the history
…undHttpException
  • Loading branch information
emodric committed Sep 3, 2020
1 parent 24028d8 commit a728ae1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions bundle/Controller/DownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Translation\TranslatorInterface;
use function str_replace;

Expand Down Expand Up @@ -77,7 +76,7 @@ public function downloadFile(Request $request, $contentId, $fieldId, $isInline =
);

if (!$content->hasFieldById($fieldId) || $content->getFieldById($fieldId)->isEmpty()) {
throw new NotFoundHttpException(
throw $this->createNotFoundException(
$this->translator->trans('download.file_not_found', [], 'ngsite')
);
}
Expand All @@ -104,7 +103,7 @@ public function downloadFile(Request $request, $contentId, $fieldId, $isInline =
$ioService = $this->ioImageService;
$binaryFile = $this->ioImageService->loadBinaryFile($binaryFieldValue->id);
} else {
throw new NotFoundHttpException(
throw $this->createNotFoundException(
$this->translator->trans('download.file_not_found', [], 'ngsite')
);
}
Expand Down
9 changes: 4 additions & 5 deletions bundle/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Validator\Constraints;
use function time;

Expand Down Expand Up @@ -208,7 +207,7 @@ public function activate(string $hash): Response
$accountKey = $this->accountKeyRepository->getByHash($hash);

if (!$accountKey instanceof EzUserAccountKey) {
throw new NotFoundHttpException();
throw $this->createNotFoundException();
}

if (time() - $accountKey->getTime() > $this->getConfigResolver()->getParameter('user.activate_hash_validity_time', 'ngsite')) {
Expand All @@ -225,7 +224,7 @@ public function activate(string $hash): Response
try {
$user = $this->userService->loadUser($accountKey->getUserId());
} catch (NotFoundException $e) {
throw new NotFoundHttpException();
throw $this->createNotFoundException();
}

$userUpdateStruct = $this->userService->newUserUpdateStruct();
Expand Down Expand Up @@ -290,7 +289,7 @@ public function resetPassword(Request $request, string $hash): Response
$accountKey = $this->accountKeyRepository->getByHash($hash);

if (!$accountKey instanceof EzUserAccountKey) {
throw new NotFoundHttpException();
throw $this->createNotFoundException();
}

if (time() - $accountKey->getTime() > $this->getConfigResolver()->getParameter('user.forgot_password_hash_validity_time', 'ngsite')) {
Expand All @@ -307,7 +306,7 @@ public function resetPassword(Request $request, string $hash): Response
try {
$user = $this->userService->loadUser($accountKey->getUserId());
} catch (NotFoundException $e) {
throw new NotFoundHttpException();
throw $this->createNotFoundException();
}

$form = $this->createResetPasswordForm();
Expand Down

0 comments on commit a728ae1

Please sign in to comment.