[Typo3-dev] Alternative to hooks - fake "$this"

dan frost dan at danfrost.co.uk
Thu Oct 28 13:45:44 CEST 2004


Ok - there's good parts to both. But really, it should be possible for 
the particular way in which something is done (its configuration) to be 
separate from when/how it is done (its implementation / the engine 
driving it). I guess this is getting into AOP.

So, in something like tcemain, a hook for processing an array would 
actually be used to implement core activities. E.g. instead of actually 
performing the act of check user permissions you'd have something like:

(i'm making this example up - i don't think this is actually in tcemain)

in each case, the _..object would default to &$this.

// check user permissions
$this->_userObject->checkUserPermissions(&$this);

// remove illegal stuff
$this->_stripObject->stripIllegalStuff(&$this):

// prep for database
$this->_databaseObject->prepForDB(&$this);

Thus, the "aspect oriented" nature of the process of putting something 
in the database is implemented by allowing the part of TYPO3 that 
instantiated this class to plug in more suitable classes.

Crazy idea - but i've used it an it reduces the lines of code 
dramatically!...

dan

Robert Lemke wrote:
> Hi Dan,
> 
> dan frost wrote:
> 
> 
>>This method puts the responsibility for implementing the hook outside
>>the class which does the work. Much nicer!
> 
> 
> Yes, but in most cases you don't want or can create extra-functions for each
> part you want to use as a hook. This is at least true for functions which
> have two or more hooks, like in TCEmain.
> 




More information about the TYPO3-dev mailing list