[TYPO3-mvc] Scheduler - Extbase repository

Domi djgarms at gmail.com
Mon Jul 8 08:21:03 CEST 2013


On 07/07/13 19:05, Peter Falk wrote:
> Hi group.
>
> I'm trying to get an instance of a repository from within the execute
> function of a scheduler task.
>
> Below is what I've done - with no luck. Don't know what i'm missing, but
> hope someone can help.
>
>
> $this->objectManager =
> \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase
> \\Object\\ObjectManager');
>
> $this->mediaRepository =
> $this->objectManager->get('TYPOCONSULT\\TcMediaPlayer\\Domain\\Repository
> \\MediaRepository');
>
> The objectManager instance is ok, but the mediaRepository instance is
> NULL
>
> Regards
> Peter
>
Hi Peter,

did you create your scheduler extension through CommandController 
(extends CommandController)? The CommandController injects the 
objectManager already, you shouldn't re-instantiate it.
$mediaRepository = 
$this->objectManager->get('TYPOCONSULT\\TcMediaPlayer\\Domain\\Repository\\MediaRepository') 
should work, otherwise there is a naming/namespace conflict. But as you 
propably don't make any use of DI inside of your MediaRepository class, 
you could simply use the GeneralUtility::makeInstance for getting the 
MediaRepository object.

Cheers,
Dominic





More information about the TYPO3-project-typo3v4mvc mailing list