[TYPO3-dev] Using Hooks in own classes

Ingo Schmitt mailinglisten at i-schmitt.de
Mon Feb 13 18:21:01 CET 2006


Hi Dan,
> How big is your class.

1000 Lines and up. (tx_commerce)
> 
> For a really "hook-able" architecture, the nicest way is:
> 
> 1. very small classes,
> 2. use ::makeInstance (or similar wrapper) to look up over-ridden classes
> 
> Can you post the structue of your class (methods + properties)?
> 

Example, our parent class fro FE rendering
1044 lines, 18 Methods. IN each methos up to 3 hooks (pre, post, process)

Ingo


> dan
> 
> Ingo Schmitt wrote:
> 
>> Hi list,
>>
>> when implementiong hooks in own classes, there are some ways to define 
>> these hooks:
>>
>> 1) Define one hook array per Method in each class
>> 2) Define one hook array per whole class and use different 
>> hook-methods in each Method
>>
>> 1 only initialises a hook object if realy used, so if a method is not 
>> called, the hookObject isn't initialised. If you use more than one 
>> hook,  more Hook Objects are created.
>>
>> 2 initiallises all hook objects for the class at creation of the class 
>> object
>>
>> (I think in general the internal costs of creation of the hook objects 
>> are in both cases almost the same)
>>
>> The Core uses Method 2, method 1 could be more elegant in the way of 
>> coding it.
>>
>>
>> Which way should I use?
>>
>>
>> Mit freundlichen Gruessen


Mit freundlichen Gruessen
-- 
Ingo Schmitt                        mailto:is at marketing-factory.de
Marketing Factory Consulting GmbH   http://typo3.marketing-factory.de/
Content Management mit Typo3: Beratung - Schulung - Realisierung




More information about the TYPO3-dev mailing list