[TYPO3-mvc] typo3.eclipse.extender with object manager in Extbase

Martin Kutschker masi-no at spam-typo3.org
Wed Oct 6 11:06:56 CEST 2010


Am 06.10.2010 10:31, schrieb Bastian Waidelich:
> Martin Kutschker wrote:
> 
>>> spl_factory_register(array(new ObjectFactory(), 'create'));
>>> $logger = new SomeLogger();
> 
>> The former code leads possibly to recursion as the first "new" will trigger a second "new" in the
>> factory.
> 
> Not really, as no factory is registered at that point.
> And if it is - it returns either an object or FALSE, in which case it would fall back to the default
> behavior, if I got it right.

But how will the factory create a new object if not with "new"?

That's why I would split up the responsibilities.

1. Find real class name for given class/interface name.

I tend to restrict this to interfaces on a language level. "new" is a after all language construct.

2. Setup the object (inject dependencies).

Basically an event listener for the instance creation. The disadvantage IMHO is that you get one
entry point for numerous classes. This could lead to an if/case-hell to act on the correct classes.

The more I think about it the less do I see the need for the proposal.

Masi


More information about the TYPO3-project-typo3v4mvc mailing list