[TYPO3-ect] Kickstarter MVC Bug: getConfiguration()

Christian Welzel gawain at camlann.de
Thu Jun 28 22:18:03 CEST 2007


Elmar Hinz wrote:

>> Do you mean something like that?
> 
> Yes it's only three words that differ. Unfortunatly you can't do this:

I asked this question in comp.lang.php and they came up with this solution:

--- quote ---
Create two different classes (the PHP5 version which extends the PHP4
version and implements the interfaces) then instantiate the proper one
using some sort of factory method.  Other than the fact that the PHP5
version implements your interfaces, the classes will behave in exactly
the same way.  For example:

class tx_lib_object extends tx_lib_selfAwareness {
    //All the tX_lib_object methods

    //The factory:
    public static factory() {
        if(t3lib_div::int_from_ver(phpversion())<5000000)
            return new tx_lib_object();
        else
            return new tx_lib_object_php5();
    }
}

if(t3lib_div::int_from_ver(phpversion())>=5000000) {
    class tx_lib_object_php5 extends tx_lib_object implements
ArrayAccess, Iterator {
        //all the methods to implement ArrayAccess and Iterator
    }
}
--- /quote ---

-- 
 MfG, Christian Welzel

  GPG-Key:     http://www.camlann.de/key.asc
  Fingerprint: 4F50 19BF 3346 36A6 CFA9 DBDC C268 6D24 70A1 AD15


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