[TYPO3-mvc] Dependeny Injection in Model class not working?
Marc Bastian Heinrichs
typo3 at mbh-web.de
Mon Aug 15 10:05:27 CEST 2011
Hey,
> in one project I need to dynamically query something using a repository in a
> model class (I need a getter for the subcatgories of a category). Is
> dependency injection as it is working in controller classes also thought for
> model classes in this case?
[...]
> Is there anyhing I need to do for this to work or is this just not
> implemented and I need to do it another way? If yes, how?
> t3lib_div::makeInstance()? Object Manager?
DI in Models will be available in extbase version 1.4 (T3 4.6)
http://git.typo3.org/TYPO3v4/CoreProjects/MVC/extbase.git?a=commit;h=c6c01d43b8682543346f378912bea06cf5304e6e
In 1.3 you could handle it like this when you need a repositiory in a model:
$objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
$this->categoryRepository =
$objectManager->get('Tx_Dedontravel_Domain_Repository_CategoryRepository');
Best
Marc Bastian
More information about the TYPO3-project-typo3v4mvc
mailing list