这是Laravel中Auth\Guard的构造函数:/***Createanewauthenticationguard.**@param\Illuminate\Auth\UserProviderInterface$provider*@param\Illuminate\Session\Store$session*@param\Symfony\Component\HttpFoundation\Request$request*@returnvoid*/publicfunction__construct(UserProviderInterface$provider,SessionStore$session,Request$request=null){$this->session=$session;$this->request=$request;$this->provider=$provider;}其中传入了参数SessionStore$session但是session的构造函数是这样的:publicfunction__construct($name,SessionHandlerInterface$handler,$id=null){$this->setId($id);$this->name=$name;$this->handler=$handler;$this->metaBag=newMetadataBag;}这里是有参数的,为什么Guard的构造函数可以自动生成session?是php原生提供的还是Laravel提供的?
2 回答
慕无忌1623718
TA贡献1744条经验 获得超4个赞
/***CreateaninstanceoftheEloquentdriver.**@return\Illuminate\Auth\Guard*/publicfunctioncreateEloquentDriver(){$provider=$this->createEloquentProvider();returnnewGuard($provider,$this->app['session.store']);}
添加回答
举报
0/150
提交
取消