[TYPO3-dev] SOLUTION (?) : Multiple XCLASS inheritance

Elmar Hinz elmar.DOT.hinz at team.MINUS.red.DOT.net
Wed Feb 8 00:21:47 CET 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bernhard Kraft schrieb:
> Jerome Schneider wrote:
> 
> Hi !!!
> 
> I think I tortured my head for days thinking about how there would be a way to
> "merge" methods of overruling "Y"CLASSES :) with a base class. This can be done
> in OO programming languages using a decorator pattern AFAIK.
> 
> But I couldn't think of any way how to do this in PHP.
> 
> I tried a little bit around if it would be possible to have variable names as
> class names like
> 
> $class = 't3lib_TCEmain';
> 
> class $class {
> 
> /* methods go here */
> 
> }
> 
> but PHP didn't like that :(
> 


I didn't try this myself. Just an idea:

$class = 'xyImplementationOfBaseClass';

eval('class baseClass extends '. $class . ' { }');

class myClass extends baseClass{

   [.....]

}

Maybe you need to include a file myClass.php after eval is done to prevent parse
errors.


/el
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFD6SuLO976RNoy/18RAqiyAKCTbeIGjMx17LrOEtT4Jz62WOTKJQCgljOr
YeAokfefNDa6XChN40s6Glw=
=P7AZ
-----END PGP SIGNATURE-----




More information about the TYPO3-dev mailing list