[TYPO3-mvc] Dependency injection in domain objects

Christian Zenker christian.zenker at 599media.de
Thu Jan 27 11:13:30 CET 2011


Hi.

After reading
http://forge.typo3.org/projects/typo3v4-mvc/wiki/Dependency_Injection_(DI)
("Dependency Injection does not work yet for Domain Objects which are  
reconstituted from the database.") it seems it is not possible to inject  
anything into a domain object. But I need a repository inside the  
models[1]. So what I do now is

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

Are there any drawbacks I need to consider? The only one I could think of  
was that Tx_Extbase_Object_ObjectManager could not be extended (except  
maybe with the ancient "ux_"-technique). I would asume that the repository  
was treated with all the extbase goodness, like DI, extending and scopes.  
Am I right about that?

Christian.

[1] For my calendar exception I use an MM-table that relates to an  
Exception- and an ExceptionGroup-table. What I want to be returned is just  
all the exceptions. So I need some custom logic for that - expect that  
Extbase does not support "group" yet.


More information about the TYPO3-project-typo3v4mvc mailing list