[TYPO3-mvc] Problem calling a repository function

Franz Koch typo3.RemoveForMessage at elements-net.de
Mon Jan 31 12:44:46 CET 2011


Hey,

>>> I can't get the objectManager in a render function of a view helper?
>>> [...]
>>> $projectRepository =
>>> $this->objectManager->get('Tx_UtekReferenzen_Domain_Repository_ProjectRepository');
>>>
>>>
>>> Gives an exception that I try to call a member function on a
>>> non-object.
>>
>> Have a look at
>> <http://forge.typo3.org/projects/typo3v4-mvc/wiki/Dependency_Injection_%28DI%29#Creating-Prototype-Objects-through-the-Object-Manager>
>>
>
> BTW: you can of course inject the repository directly:
...

or if both fail:

$objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
$repository = $objectManager->get('...');

But using DI as Bastian mentioned is the preferable solution in this case.
-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list