[Typo3-dev] Library manager instead of globals

René Fritz r.fritz at colorcube.de
Tue Mar 16 16:02:44 CET 2004


> > $myObject = t3lib_div::makeInstanceService('ServiceType or ServiceKey');
>
> As far as I read the code in RC1 you can use only the type. But you can
> disallow (!) service implementations explicetly by naming their keys as
> an extra paramater.

The service keys are also registered as service type, therefore it's possible 
to get a service by it's key. To make that work service types with prefix tx_ 
and user_ are disallowed.

>
> > BTW: I have a problem with services related to the fact that php4 have no
> > real destructors.  All my tests with

> I guess you read all those nice comments on
> http://www.php.net/manual/en/function.register-shutdown-function.php ?

Yes but it didn't helped :-)

> BTW in RC3.6 makeInstanceService() doesn't use a & before the function
> name. A comment asks "objects are passed always as reference - right?"
> The answer is no. Objects are always copied in 4.x unless you specfiy
> it. The function and the assignement need a &. Though in 5.0 this has
> been changed someway or other.
>
> So you'd need a $obj =& t3lib_div::makeInstance($info['className']); as
> well.

I tried that but it didn't worked. Maybe I made a mistake somewhere. I have to 
check again.
Is it a bad idea to change makeInstance() into
function &makeInstance() anyways?

> PS: I changed once all occurences of "$obj = t3lib_div::makeInstance()"
> into "$obj =& t3lib_div::makeInstance()". Made makeInstance return a ref
> by adding a & and it worked out allright for 3.5. The only thing that
> broke was the extension manager or something else that had a weird class
> loading mechanism that worked via globals.
>
> I can find the file in question if anyone is interested.

Would that still work with php5?

René

-- 
COLORCUBE
digital media lab

www.colorcube.de





More information about the TYPO3-dev mailing list