I got a commandController like this (using TYPO3 6.1):
class MyCommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandController {
/**
* fileRepository
*
* @var \VENDOR\MyExt\Domain\Repository\FileRepository
* @inject
*/
protected $fileRepository;
}
but when i try cast
$this->fileRepository->findAll();
i get:
Fatal error: Call to a member function findAll() on a non-object in
looks like the repostory is not autoinjected with @inject like it is in ActionControllers.
How do i inject the repository manually?
you can inject repositories in your commandcontroller. after adding a @inject in your doccomments you have to delete the cache and/or the cachefiles?
Indeed, you need to clear the caches. Apparently in my case on Typo3 6.2 it only worked when I cleared the caches from the Install tool.

Note: I got this tip after reading a blog post on scripting-base.de (in German).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With