[Typo3-dev] Library manager instead of globals

René Fritz r.fritz at colorcube.de
Tue Mar 16 14:57:20 CET 2004


Hi Dan

This seems to be very much the same like services but with a little different 
point of view. Maybe there's something in your solution which could enhance 
the services?

> $GLOBALS['LIBS']['myLib']->addLibraryEntry('libraryKey',
> array('class'=>'classname', 'metadata'=>'etc'));
>
> instead or as well as the of the "include once" stuff at the bottom of
> source files.

ext_tables.php / ext_localconf.php:
t3lib_extMgm::addService($_EXTKEY,  ''ServiceType ',  'ServiceKey', ...

> Then, when you want an object:
> $myObject = $GLOBALS['LIBS']['myLib']->getLibraryEntryOb('libraryKey');

$myObject = t3lib_div::makeInstanceService('ServiceType or ServiceKey');


> 1. you can have a default "object" or register errors when non-existent
> objects are created

With services you simply don't get an object id there's no class availbale.
Services allow to get an object by the service type (give me one of that type) 
or by the service key (give me exact that object). You can do a little 
more...

> 2. you can have lots of classes supplying the same "class name"
> (libraryKey) - so for extensions you can have:

like in services.

> The library object can also create "sub libraries" based on, for
> example, permissions, user's location.

What does this mean?


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

register_shutdown_function(array(&$this, '__destruct'));

did not work, because the function seems to make a copy of the object and 
don't take the reference. Therefore the data of the object is - while 
destruction - not the same like the 'real' object.

I made many tests and added & to makeInstance() to return a reference but 
nothing works.

Any hints?

greetings
René

-- 
COLORCUBE
digital media lab

www.colorcube.de





More information about the TYPO3-dev mailing list