[TYPO3-core] RFC #9505: Make the caches in TYPO3 use the new caching framework
Ernesto Baschny [cron IT]
ernst at cron-it.de
Thu Oct 9 13:51:39 CEST 2008
Martin Kutschker wrote: on 08.10.2008 10:01:
>>> I suggested this once, but Robert told me that singletons are bad when
>>> it comes to unit tests. I don't know, but maybe it helps (for unit
>>> tests) if t3lib_div::makeInstance() would test if the class implements a
>>> certain (fake) interface or has a certain doc comment set and stores a
>>> reference to the object in a static variable.
>> Nice idea, I would welcome that, too!
>
> Which one? There are two proposals.
Having an interface (why "fake"?) for singletons which makeInstance is
aware of.
e.g.
class t3lib_db implements typo3_singleton {
...
}
and use that with:
$db = t3lib::makeInstance($t3lib_db);
would give us the same $db again and again, no matter how often (and
where) it is called.
The singleton is initialized only once (when it is first being
requested), so that we don't need a pollution of singletons as global
vars which "maybe someone will need it". Just create them when they are
really needed.
Cheers,
Ernesto
More information about the TYPO3-team-core
mailing list