简体   繁体   English

无法在某些 controller Typo3 上注入存储库

[英]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”

TYPO3 now requires to configure dependency injection. TYPO3 现在需要配置依赖注入。 It does not work automatically any more.它不再自动工作。 Basically you need to add a special Configuration/Services.yaml file.基本上你需要添加一个特殊的Configuration/Services.yaml文件。 See here how to configure it.请参阅此处如何配置它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TYPO3 v9.5.11 Extbase:将ContainerClass生成的ServiceObject注入Repository - TYPO3 v9.5.11 Extbase: Inject ServiceObject generated by a ContainerClass into Repository TYPO3:使用构造函数将服务类注入到 AuthServiceClass 中 - TYPO3: Inject Service Classes into AuthServiceClass with Constructor TYPO3:“注入”是否意味着“需要”? - TYPO3: Does “inject” imply “require”? TYPO3 如何在钩子中注入 objectManager? - TYPO3 how to inject objectManager in hook? 将教义存储库注入控制器 - Inject Doctrine Repository into controller 在某些情况下无法将EntityManager注入构造函数 - Can't inject EntityManager to constructor in some circumstances 我无法在 Android 中使用 HILT 将 Dao 注入到存储库 Class - I can't inject Dao to a Repository Class, with HILT, in Android 如何使用StructureMap将存储库类注入控制器? - How to use StructureMap to inject repository classes to the controller? Android Dagger 2一些构造函数无法注入ViewModel - Android Dagger 2 Some Constructors can't Inject into ViewModel :[$ injector:unpr] angularjs中的未知提供程序无法将工厂注入控制器 - : [$injector:unpr] Unknown provider in angularjs can't inject factory into controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM