[TYPO3-mvc] "= new" vs "t3lib_div::makeInstance()" in Extbase

Jochen Rau jochen.rau at typoplanet.de
Wed Apr 7 11:12:49 CEST 2010


Hi Masi.

On 05.04.10 18:45, Martin Kutschker wrote:
> In Extbase quite a number of objects don't use makeInstance. IMHO that's a pity because you'll loose
> a very nice feature of v4: XCLASSes. Perhaps with APO in v5 things can be differently, but for a v4
> extension I consider these occurences as bugs.
>
> Do you agree? Shall I file a bug?

I agree to implement the ability to able to alter existing code. But the 
concept of XCLASS isn't nice. It may solve real world problems as stated 
by Sebastian in a later post but it introduces real world problems, too.

I am really a fan of polymorphism. It's much cleaner and a language 
feature. So porting framework and extension code is much easier.

Using XCLASS isn't really related to the autoload feature. It's more 
related to the Object Management not implemented in Extbase.

So what's needed? IMO there are two possible solutions:

1) improve the makeInstance to be able to instanciate the "best" 
implementation for an interface (maybe by adding a hook inside 
makeInstance) and use makeInstance in the Extbase and Extension code. 
The "best" implementation will be determined by configuration (cropping 
"Interface" from the class name) and configuration (TypoScript).
2) Backport the Object Management framework from FLOW3 and use 
$objectManager->get().

I tend to implement the 1st solution as the Object Management Framework 
is a huge bunch of code related to other concepts (like the PHP file 
cache). And the 1st solution makes the usage of legacy code 
("makeInstance") explicit.

What's your opinion?

Regards
Jochen


More information about the TYPO3-project-typo3v4mvc mailing list