[TYPO3-ect] div/lib extensions

Elmar Hinz elmar.DOT.hinz at team.MINUS.red.DOT.net
Tue May 2 18:48:07 CEST 2006


Ernesto Baschny [cron IT] schrieb:
> Hi Elmar and Elmar-fans,
> 

Hi Ernesto and all,

back again. I was a little absent lately spending my time to finish the
script of the second edition of our TYPO3-Book wich will be published
someday in June. I have dedicated a chapter to div/lib so it is time push
them forward now. :-)

Well, I think I am not really the right object for fan-atism. ;-) I live
fine with my own self-respect.


> In my current project, I'm starting to use the proposed div/lib
> extensions. Here are my first impressions and suggestions:
> 
> They currently only work on PHP5, but the changes needed to make it work
> also on PHP4 are very small (and I did it, because I need my extension
> working on PHP4):
> 
> 1) change "self::" with "<classname>::", as "self" is not known. In this
> particular cases it shouldn't matter (1x in div/class.tx_div.php and 3x
> in lib/class.tx_lib_t3Loader.php).
> 2) remove the "private function v", as "private" is not known in PHP4.
> These functions seems not to be used anyway.
> 

O.K.

> 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
>         $className = str_tolower($className);
>         if (!array_key_exists($className, $instances)) {
>             // instance does not exist, so create it
>             $instances[$class] =& tx_div::makeInstance($class, $type);
>         }
>         $instance =& $instances[$class];
>         return $instance;
>     }
> 
> 

How about static $instances and PHP4? Never heard of static in PHP4. But
could be replaced with a global if not available there.


> And while I am not a 100%-fan of the TYPO3 coding style, it would be
> nice to use it in these extensions to set an example. In this case,
> indenting with a TAB, using TABs before opening "{" and using phpdoc
> comments like in TYPO3-core (@params instead of @par). Maybe others, but
> those are the ones that I first noticed.

Right that is a point I need to work on. I have simply set my Emacs to PEAR
compatibility, wich means spaces instead of TABs. I need to do a more
finegrained configuration.


Jan-Hendrik did some experiments with the symphony-framwork meanwhile and
is very enthusiastic. That brings up the question wich traks to follow.
Currently I think it is worth to follow both traks. The symphony-trak for
individual customer setups and the lib/div trak for public extensions.
Well, I see that will need a more detailed discussion in an own thread. I
just wanted to hint to this.



Regards

Elmar



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