[TYPO3-dev] Best-practice: dependencies in Controllers

Jennifer Koenig jenka13all at gmail.com
Tue Feb 11 23:30:37 CET 2014


This is a best-practice question about working with dependencies in controllers. I know that I can use the @inject annotation for repositories and for domain models, but what's the best way to call the methods of a controller from within a different controller? 

I'm using Typo3 4.7

What's cleanest and / or fastest? Using t3lib::makeInstance(), or objectManager::create() or objectManager::get() ? I find all kinds of contradictory information when I'm googling.

Could there be a reason why, in a controller, using the @inject annotation on a repository might not work? (Error - "call to method xxx() from a non-object). Does the order of injection matter? Why is it possible to use @inject for repositories and not for other objects (like other controllers)? 

These are questions I can't find the answers to anywhere. Would anyone care to share their wisdom?



More information about the TYPO3-dev mailing list