[TYPO3-mvc] dependency injection

Felix Oertel mehl at foertel.com
Fri Jul 30 09:36:31 CEST 2010


Hey Sebastian,

thanks for taking the time to look at this.

Am 30.07.10 07:29, schrieb Sebastian Kurfürst:
> hope you don't mind the nit-picking ;)

ha ! give to me ...

> - Instead of "Object_Manager", it should be called
> "Object_ObjectManager" (same for the ManagerInterface)

Then we should think about the Persistence_Manager, Property_Mapper, and 
so on. What I want to say, we should decide to either match FLOW3 naming 
or not ... but I don't want to call the objectManager 
Object_ObjectManager and the persistenceManager Persistence_Manager.

> - "getObject" should be called "get", and there should be an additional
> method "create" inside ObjectManagerInterface.

Erm ... getObject is just for compatibility reasons and marked 
deprecated. The work happens in get(). I agree on the create() method.

> - "getObject" can be removed inside Object_Manager, as it has never been
> a public API, and only used inside Extbase, right?

I don't think it would hurt to keep it for two more releases and mark it 
deprecated. This is, how stuff in the core is cleaned up ... but of 
course we are beta software and have some more possibilities. Up to all 
of you ...

> - please remove the API annotations for now, as it is not yet stable
> enough for a public API.

ok ;-)

> - you should call an "initializeObject" after DI has been finished, as
> you cannot use the constructor for such initializations.

You're right. This was one Todo, to see how we can avoid magic 
constructor methods (since the injected stuff is not available there).

> The main issue I see right now is the speed problem inside "injectDependencies", as you use uncached reflection there.

Ya, as mentioned this is hacked. ;-) I didn't care for speed too much 
... I'll try to come up with a good caching concept.

> should not get worse... But we'd definitely need to profile this and measure if Extbase gets slower by DI.

Yep ... I'll add a little profiler later on, to be activated by 
?PROFILE_DI=1 just to have some in-place times ...

> (The Profiler whould be helpful now ;-) ;-) )

He He, yaa yaa, do you try to make some point? :-P (Unfortunately the 
day has only 24 hours ... )

> To solve the speed issue, FLOW3 creates a PHP file which hard-wires the dependencies of objects together -- and this is then really fast, but I fear that's not a feasible solution in Extbase.

I will have a look at this. To create PHP Files is not that big a 
problem as we could use the caching framework to store and require them 
... let's see, if it's worth it.

> Thanks again for all the work :-)

Welcome ...

> I think it's a nice feature, and if we solve the speed issue, I see no problem in including it in Extbase core.

Ok, I really didn't see that coming (so fast) ... but the faster the 
better ;-) I'll try to provide solutions to your "nits" <:-P over the 
weekend.

> It's no constructor injection,  no @inject annotation and the like, but it's definitely enough to get people started with Dependency Injection.

I tried to (at least a little) get along with FLOW3 ... they don't have 
@inject, do they?

Do you think @inject would suit better? It would not be that much work 
to make @inject work an I think it's cleaner then iterating all methods 
searching for inject*() ...

regards, foertel


More information about the TYPO3-project-typo3v4mvc mailing list