2
我正在研究yii2的依赖注入,我发现了一些非常有用的主题,Controller action injection。我试过了,但它不起作用。我已经完成了所有谷歌的事情和事件阅读yii2框架的源代码,我错过了什么? 这里是我的代码:yii2控制器动作注入是如何工作的
//my action
public function actionIndex(JobService $jobService) {
//logic code
}
//i register the dependencies in the bootstrap file
// and yes ,i tried \Yii::$container->set('JobService', '\hr\services\JobService') too
\Yii::$container->set('\hr\services\JobService', '\hr\services\JobService');
这真的很有帮助,tks! – dzthink
我真的很困惑,为什么yii官方将这个功能写入文档,而最新版本仍然没有实现 – dzthink