[TYPO3-mvc] Thoughts regarding inter-extension communication

Reinhard Führicht rf at typoheads.at
Tue Oct 6 18:43:14 CEST 2009


Joerg Schoppet schrieb:
> Hi,
> 
> Prerequisite:
> everything extbase-dependant
> 
> following scenario:
> I wrote a general billing extension. And created a be-module, in which I 
> can create positions and finally invoices.
> 
> Now I have additional extensions, which should "hook" into the billing 
> extension to provide "specialized" billing-positions.
> 
> Actual solution:
> In the billing-extension I created an own class, which is a singleton 
> and has a method called "registerExtension". All the specialized 
> extensions have a call in ext_tables.php, which registers an own class 
> as a string:
> $obj = t3lib_div::makeInstance('Tx_JrCustomer_Utility_Billing');
> $obj->registerExtension('Tx_JrDomainManagement_Utility_Billing');
> 
> In the class from the billing-extension I can then call the following 
> method:
>         public function fetchBillings($year, $month) {
> 
>                 foreach ($this->billings as $extension) {
>                         $obj = t3lib_div::makeInstance($extension);
>                         $this->positions = array_merge($this->positions, 
> $obj->fetchPositions($year, $month));
>                 }
> 
>         }
> 
> 
> What I don't like at this solution is:
> When ext_tables.php is executed the extbase-dispatcher is not loaded, so 
> I have to use "require_once"-call for the main class in ext_tables.php.
> Because of this I also have to register the specialized classes as 
> strings, so that I haven't to include this all with require_once.
> 
> 
> Is there a better solution for this usecase? Perhaps something 
> completely different?
> 
> Joerg

I use TypoScript configuration to register the classes.

Something like

billings {
   1 = Tx_SomeExt_SomeClass
   2 = Tx_SomeOtherExt_SomeOtherClass
}

which is quite handy when you use a component based approach. This way 
any component can be extended by another extension and entered in 
TypoScript. Furthermore I used an approach that components can be 
chained which is suitable for my use case.

The TypoScript approach is IMHO quite good for frontend plugins. For 
backend oriented extensions you could use page TS or usergroup TS.

Regards,
Reinhard


-- 
mit freundlichen Grüßen,

Reinhard Führicht MSc
Entwickler

---------------------------------------------------

TYPOHEADS
WEB ENGINEERING
www.typoheads.at


More information about the TYPO3-project-typo3v4mvc mailing list