On Jun 28, 3:36 pm, Christian Welzel <gaw...@camlann .dewrote:
Hi there!
Currently i'm thinking about how to solve this problem:
if (t3lib_div::int _from_ver(phpve rsion())<500000 0) {
// php4
class tx_lib_object extends tx_lib_selfAwar eness {...}
//} else {
// php5
class tx_lib_object extends tx_lib_selfAwar eness implements ArrayAccess, Iterator {...}
//
}
The question is now how to make this conditional "implements " in php?
Of cause i do not want to copy the code for both php versions and then
switch between the whole classes.
--
MfG, Christian Welzel aka Gawain@Regenbog en
GPG-Key: http://www.camlann.de/key.asc
Fingerprint: 4F50 19BF 3346 36A6 CFA9 DBDC C268 6D24 70A1 AD15
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_selfAwar eness {
//All the tX_lib_object methods
//The factory:
public static factory() {
if(t3lib_div::i nt_from_ver(php version())<5000 000)
return new tx_lib_object() ;
else
return new tx_lib_object_p hp5();
}
}
if(t3lib_div::i nt_from_ver(php version())>=500 0000) {
class tx_lib_object_p hp5 extends tx_lib_object implements
ArrayAccess, Iterator {
//all the methods to implement ArrayAccess and Iterator
}
}