有时,一个类可能具有可变的依赖关系,该依赖关系被类型提示为给定的类(Report ... $reports
)。使用 needs
和 giveTagged
方法,您可以轻松地为给定依赖项注入带有该标签的所有容器绑定:
$this->app->when(ReportAggregator::class)
->needs(Report::class)
->giveTagged('reports');
以上内容是否对您有帮助:
W3Cschool
恭喜您成为首批注册用户
获得88经验值奖励
有时,一个类可能具有可变的依赖关系,该依赖关系被类型提示为给定的类(Report ... $reports
)。使用 needs
和 giveTagged
方法,您可以轻松地为给定依赖项注入带有该标签的所有容器绑定:
$this->app->when(ReportAggregator::class)
->needs(Report::class)
->giveTagged('reports');
Copyright©2021 w3cschool编程狮|闽ICP备15016281号-3|闽公网安备35020302033924号
违法和不良信息举报电话:173-0602-2364|举报邮箱:jubao@eeedong.com
扫描二维码
下载编程狮App
编程狮公众号
联系方式:
更多建议: