Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ability to override default error view paths #51293

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Illuminate/Foundation/Configuration/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ public function report(callable $using)
return $this->handler->reportable($using);
}

/**
* Register error view paths callback.
*
* @param callable $using
* @return void
*/
public function registerErrorViewPathsUsing(callable $using)
{
$this->handler->registerErrorViewPathsUsing($using);
}

/**
* Register a reportable callback.
*
Expand Down
23 changes: 23 additions & 0 deletions src/Illuminate/Foundation/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ class Handler implements ExceptionHandlerContract
*/
protected $finalizeResponseCallback;

/**
* The callback that should be used to register the application's error view paths.
*
* @var callable|null
*/
protected $registerErrorViewPathsUsing;

/**
* The registered exception mappings.
*
Expand Down Expand Up @@ -233,6 +240,17 @@ public function renderable(callable $renderUsing)
return $this;
}

/**
* Register error view paths callback.
*
* @param callable $using
* @return void
*/
public function registerErrorViewPathsUsing(callable $using)
{
$this->registerErrorViewPathsUsing = $using;
}

/**
* Register a new exception mapping.
*
Expand Down Expand Up @@ -897,6 +915,11 @@ protected function renderHttpException(HttpExceptionInterface $e)
*/
protected function registerErrorViewPaths()
{
if (! is_null($this->registerErrorViewPathsUsing)) {
call_user_func($this->registerErrorViewPathsUsing);

return;
}
(new RegisterErrorViewPaths)();
}

Expand Down