In my custom controller, i'm trying to inject a repository as a dependecy, like this
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.
But this injection is working on this controller, but I can't figure out why...
class NewsController extends 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"
TYPO3 now requires to configure dependency injection. It does not work automatically any more. Basically you need to add a special
Configuration/Services.yamlfile. See here how to configure it.