RegisterErrorViewPaths.php
TLDR
This file, RegisterErrorViewPaths.php
, is a part of the Illuminate\Foundation\Exceptions
namespace in the Demo Projects project. It contains a class named RegisterErrorViewPaths
with a method called __invoke()
. The purpose of this file is to register the error view paths in the application.
Methods
__invoke()
This method registers the error view paths in the application. It replaces the namespace errors
with a collection of view paths obtained from the config('view.paths')
configuration. The method then adds the errors
subdirectory to each path in the collection and pushes the __DIR__.'/views'
path at the end. Finally, it sets the updated view paths as the replacement namespace for the errors
.
Classes
Class: RegisterErrorViewPaths
This class registers the error view paths in the application. It contains a single method, __invoke()
, which performs the registration process described above.
<?php
namespace Illuminate\Foundation\Exceptions;
use Illuminate\Support\Facades\View;
class RegisterErrorViewPaths
{
/**
* Register the error view paths.
*
* @return void
*/
public function __invoke()
{
View::replaceNamespace('errors', collect(config('view.paths'))->map(function ($path) {
return "{$path}/errors";
})->push(__DIR__.'/views')->all());
}
}