diff --git a/src/Illuminate/Foundation/Configuration/Exceptions.php b/src/Illuminate/Foundation/Configuration/Exceptions.php index 532cb06d7e4f..b41921566ab4 100644 --- a/src/Illuminate/Foundation/Configuration/Exceptions.php +++ b/src/Illuminate/Foundation/Configuration/Exceptions.php @@ -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. * diff --git a/src/Illuminate/Foundation/Exceptions/Handler.php b/src/Illuminate/Foundation/Exceptions/Handler.php index 7d049553737e..fddb8bfb792a 100644 --- a/src/Illuminate/Foundation/Exceptions/Handler.php +++ b/src/Illuminate/Foundation/Exceptions/Handler.php @@ -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. * @@ -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. * @@ -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)(); }