[TYPO3-ect] div/lib extensions

Elmar Hinz elmar.DOT.hinz at team.MINUS.red.DOT.net
Mon Jul 10 02:11:02 CEST 2006


Hi Ernesto,

I still haven't implemented your proposals, yet. My first target was to get
the library into SVN so that people can do direct improvements. Well, SVN
is done now.

svn ls https://svn.sourceforge.net/svnroot/typo3xdev/tx_lib
svn ls https://svn.sourceforge.net/svnroot/typo3xdev/tx_div
svn ls https://svn.sourceforge.net/svnroot/typo3xdev/tx_articles

Maybe you find a way to fix the source directly. Else I will do that during
 my next working cycle.

Regards

Elmar



Ernesto Baschny [cron IT] wrote:
> Elmar Hinz schrieb am 02.05.2006 18:48:
> 
>> Well, I think I am not really the right object for fan-atism. ;-) I live
>> fine with my own self-respect.
> 
> True, but your work is very good here, so this was is a way to motivate
> you to keep up the nice work.
> 
>>> Other than that I needed an easy way of generating singletons of some of
>>> my classes. The easiest and most generic method I found is the one
>>> described in [1]: a helper class. It would be cool to have such a helper
>>> as tx_div::getSingleton($className) which could also use the fancy
>>> "class finder" routines (load et all). Something like:
>>>
>>>     /**
>>>      * Static method to get a singleton
>>>      *
>>>      * @param   string  classname 'tx_key_path_file'
>>>      * @param   mixed   loadertype 't3', 'pear', 'classPear', 'hippie'
>>> resp. 2, 3, 6, 9, 68
>>>      * @return  object  the instance else FALSE
>>>      */
>>>     function getSingleton($className, $type = 3) {
>>>         static $instances = array();  // array of instance names
> 
>> How about static $instances and PHP4? Never heard of static in PHP4. But
>> could be replaced with a global if not available there.
> 
> Static variables in functions have been around since the start of PHP4.
> But what I just found out, that references (to objects) in static
> variables doesn't work as expected, see last example in
> http://www.php.net/manual/en/language.variables.scope.php.
> 
> In my quick tests, this seems to work:
> 
>     function &getSingleton($className, $type = 3) {
>         static $instances = array();  // array of instance names
>         $className = strtolower($className);
>         if (!array_key_exists($className, $instances)) {
>             // instance does not exist, so create it
>             $instances[$className] = tx_div::makeInstance($className,
> $type);
>         }
>         return $instances[$className];
>     }
> 
> 
> 
> Cheers,
> Ernesto



More information about the TYPO3-team-extension-coordination mailing list