throw runtime error with static pages only if debug

This commit is contained in:
Jérémy Munsch 2023-03-02 10:06:41 +01:00
parent dab6f5aa0e
commit 4a3ebac562
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC

View file

@ -33,12 +33,12 @@ class StaticPageController extends Controller
/**
* Display a static page
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Site\StaticPage $static_page_front
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
* @throws \RuntimeException If the static page type is not handled.
*/
public function displayStaticPage(Request $request, StaticPage $static_page_front)
public function displayStaticPage(StaticPage $static_page_front, Request $request)
{
$static_page = $static_page_front;
switch ($static_page->type) {
@ -53,7 +53,10 @@ class StaticPageController extends Controller
return view('theme::pages.static-page', compact('static_page'));
case StaticPageType::crud():
default:
throw new \RuntimeException("Unhandled static page {$static_page->type->label}");
if (\config('app.debug')) {
throw new \RuntimeException("Unhandled static page {$static_page->type->label}");
}
\abort(404);
}
}
@ -67,7 +70,10 @@ class StaticPageController extends Controller
public function displayCrudStaticPage(StaticPage $static_page)
{
if (!$static_page->type->equals(StaticPageType::crud())) {
throw new \RuntimeException("Unhandled static page {$static_page->type->label}");
if (\config('app.debug')) {
throw new \RuntimeException("Unhandled static page {$static_page->type->label}");
}
\abort(404);
}
return view('theme::pages.static-page', compact('static_page'));
}