[英]Can't inject repository on some controller Typo3
In my custom controller, i'm trying to inject a repository as a dependecy, like this在我的自定义 controller 中,我正在尝试将存储库作为依赖注入,就像这样
class FundedProjectController extends ActionController {
/**
* @var \GeorgRinger\News\Domain\Repository\NewsRepository
*/
protected $newsRepository;
/**
* Inject a news repository to enable DI
*
* @param \GeorgRinger\News\Domain\Repository\NewsRepository $newsRepository
*/
public function injectNewsRepository(\GeorgRinger\News\Domain\Repository\NewsRepository $newsRepository)
{
$this->newsRepository = $newsRepository;
}
...
But when I call it in my previewAction , i have an error saying that my $this->newsRepository is null.但是当我在我的previewAction中调用它时,我有一个错误说我的 $this->newsRepository 是 null。
But this injection is working on this controller, but I can't figure out why...但是这种注入正在处理这个 controller,但我不知道为什么......
class NewsController extends NewsBaseController class NewsController 扩展 NewsBaseController
I'm working on 7.6.32, stagging website but production mode enable, all caches cleared (also tried with ?no_cache=1 , also tried with "@inject"我正在开发 7.6.32,暂存网站但启用生产模式,清除所有缓存(也尝试使用?no_cache=1 ,也尝试使用“@inject”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.