PasswordResetServiceProvider.php
TLDR
This file, PasswordResetServiceProvider.php
, is a service provider class in the Illuminate\Auth\Passwords namespace. It registers a password broker instance in the Laravel application.
Methods
register
This method is responsible for registering the service provider. It calls the registerPasswordBroker
method.
registerPasswordBroker
This method registers the password broker instance in the application's service container. It uses the singleton method to bind the 'auth.password' key to a new instance of the PasswordBrokerManager class. It also binds the 'auth.password.broker' key to a closure that resolves the 'auth.password' instance.
provides
This method returns an array of services provided by the provider. In this case, it returns ['auth.password', 'auth.password.broker'].
<?php
namespace Illuminate\Auth\Passwords;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
class PasswordResetServiceProvider extends ServiceProvider implements DeferrableProvider
{
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->registerPasswordBroker();
}
/**
* Register the password broker instance.
*
* @return void
*/
protected function registerPasswordBroker()
{
$this->app->singleton('auth.password', function ($app) {
return new PasswordBrokerManager($app);
});
$this->app->bind('auth.password.broker', function ($app) {
return $app->make('auth.password')->broker();
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return ['auth.password', 'auth.password.broker'];
}
}