This is the AuthGuard constructor in Laravel: {code ...} the SessionStore $ session parameter is passed in, but the session constructor is like this: {code ...} here there are parameters. Why does the Guard constructor automatically generate a session? Is provided by php native... this is
Laravel
Medium
Auth\Guard
Constructor:
/** * Create a new authentication guard. * * @param \Illuminate\Auth\UserProviderInterface $provider * @param \Illuminate\Session\Store $session * @param \Symfony\Component\HttpFoundation\Request $request * @return void */ public function __construct(UserProviderInterface $provider, SessionStore $session, Request $request = null) { $this->session = $session; $this->request = $request; $this->provider = $provider; }
Parameters are input.SessionStore $session
Howeversession
The constructor of is as follows:
public function __construct($name, SessionHandlerInterface $handler, $id = null) { $this->setId($id); $this->name = $name; $this->handler = $handler; $this->metaBag = new MetadataBag; }
There are parameters here. Why?Guard
The constructor of can be automatically generated.session
?
Yesphp
Native providesLaravel
Provided?
Reply content:
This isLaravel
MediumAuth\Guard
Constructor:
/** * Create a new authentication guard. * * @param \Illuminate\Auth\UserProviderInterface $provider * @param \Illuminate\Session\Store $session * @param \Symfony\Component\HttpFoundation\Request $request * @return void */ public function __construct(UserProviderInterface $provider, SessionStore $session, Request $request = null) { $this->session = $session; $this->request = $request; $this->provider = $provider; }
Parameters are input.SessionStore $session
Howeversession
The constructor of is as follows:
public function __construct($name, SessionHandlerInterface $handler, $id = null) { $this->setId($id); $this->name = $name; $this->handler = $handler; $this->metaBag = new MetadataBag; }
There are parameters here. Why?Guard
The constructor of can be automatically generated.session
?
Yesphp
Native providesLaravel
Provided?
Https://github.com/laravel/framework/blob/4.2/src/Illuminate/Auth/AuthManager.php#L51
/** * Create an instance of the Eloquent driver. * * @return \Illuminate\Auth\Guard */public function createEloquentDriver(){ $provider = $this->createEloquentProvider(); return new Guard($provider, $this->app['session.store']);}