[Typo3-dev] extending extensions

"Kasper Skårhøj" kasper at typo3.com
Wed Jan 14 18:14:23 CET 2004


I don't see that we are solving problems. if you want a warning that the same class is extended by more than one extension I think the EM could be made to do that.

BUT the main problem still is that we need to cascade the extensions automatically if this problem is to be solved.

I outline the problem here:



here two extensions (1 and 2) are both extending "Base Class":

EXT1
  |
BaseClass


EXT2
  | 
BaseClass




As it is right now ONE of them will win - the one loaded last in the extension repository.
This means that 

EXT2
  | 
BaseClass


... is what we get (if EXT2 was loaded after EXT1)



Now, what we really would like is to have something like this:


EXT2
  | 
EXT1
  |
BaseClass


This is only possible if EXT2 contains two setups namely:



EXT2
  | 
EXT1


and 


EXT2
  |
BaseClass





This is now possible wit hthe adjustments to makeInstance that ingmar originally posted and I have implemented in 3.6.0.

BUT the problem still is that EXT2 must:
- explicitly address compliance with EXT1
- create and configure TWO identical extension classes, one for each scenario.

This is not scalable really, before you know you have to explicitly address compliance with 5, 10 and soon hundred other extensions with the same number of redundant files.






In pseudo PHP code this is what could solve the problem:



class ux_


// Base class:
class tslib_content {
}
// This sets a registy telling which class to instantiate if we need "tslib_content" - by default that is of course "tslib_content"
$GLOBALS['classExtensionRegistry']['tslib_content'] = 'tslib_content';	


// First extension:
class myClassExtensionToTslibContent_1 extends $GLOBALS['classExtensionRegistry']['tslib_content'] {
}
// Now, the registry is changed because "myClassExtensionToTslibContent" is the class to extend and instantiate in case "tslib_content" is needed...
$GLOBALS['classExtensionRegistry']['tslib_content'] = 'myClassExtensionToTslibContent_1';	



// Second extension:
class myClassExtensionToTslibContent_2 extends $GLOBALS['classExtensionRegistry']['tslib_content'] {
}
$GLOBALS['classExtensionRegistry']['tslib_content'] = 'myClassExtensionToTslibContent_2';	


// Third extension:
class myClassExtensionToTslibContent_3 extends $GLOBALS['classExtensionRegistry']['tslib_content'] {
}
$GLOBALS['classExtensionRegistry']['tslib_content'] = 'myClassExtensionToTslibContent_3';	




And getting an instance:

$object = new $GLOBALS['classExtensionRegistry']['tslib_content']


... giving us this class:


myClassExtensionToTslibContent_3
       |
myClassExtensionToTslibContent_2
       |
myClassExtensionToTslibContent_1
       |
tslib_content



... effectively letting all extensions affect the final instance.


This is what we want but cant get because PHP does not allow us to declare


class blablabla extends $someClassname {
}




God bless

- kasper

*********** REPLY SEPARATOR  ***********

On 14-01-2004 at 10:59 Carlos Chiari (DE) wrote:

>Hi:
>
>Just another idea,
>
>The extending method could benefit from a line like this:
>
>$TYPO3_CONF_VARS["BE"]["XCLASS"]["typo3/class.myclass.php"][ ] =
>PATH_typo3conf."class.ux_myclass.php";
>
>
>$TYPO3_CONF_VARS["BE"]["XCLASS"]["typo3/class.myclass.php"]['ExtendingOrder'
>][] = $_EXTKEY;
>
>The first line will always look for the the maximum of the existing integer
>indices and add 1 to make the new key.
>The second line will provide the developer with an array where to find the
>order in which the class was extended, in case debuggin is needed.
>
>Regards
>
>Carlos
>
>
>----- Original Message ----- 
>From: "Carlos Chiari (DE)" <ccho at dimension-e.net>
>To: <bnscs at gmx.de>; "List for Core-/Extension development"
><typo3-dev at lists.netfielders.de>
>Sent: Wednesday, January 14, 2004 10:44 AM
>Subject: Re: [Typo3-dev] extending extensions
>
>
>> Hi:
>>
>> Can we use some sort of global var/array key-value  to know how many
>times
>a
>> class has been "extended"?
>>
>>
>> 1. Instead of
>>
>> $TYPO3_CONF_VARS["BE"]["XCLASS"]["typo3/class.myclass.php"] =
>> PATH_typo3conf."class.ux_myclass.php";
>>
>> in ext_localconf.php, we could use
>>
>> $TYPO3_CONF_VARS["BE"]["XCLASS"]["typo3/class.myclass.php"][] =
>> PATH_typo3conf."class.ux_myclass.php";
>>
>> ^^^
>>
>> Then, at the function makeInstance, we look for this key to find out how
>> many times the extension has been extended, and do the proper
>adjustments.
>>
>>
>> Maybe this could help?
>>
>> Carlos
>>
>>
>
>
>
>_______________________________________________
>Typo3-dev mailing list
>Typo3-dev at lists.netfielders.de
>http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev



God bless

- kasper
- kasper

--------------------- o ---------------------
Mange kokke fordærver maden.








More information about the TYPO3-dev mailing list