[TYPO3-dev] Custom functions in Hooks?

Jigal van Hemert jigal at xs4all.nl
Sun Aug 7 15:41:01 CEST 2011


Hi,

On 7-8-2011 14:40, ktt wrote:
> Is it possible to use/declare and call custom functions inside a
> hook'ed class? Or they should be declared in ext_localconf.php
> first?

A hook creates an instance of your hook subscriber class first and then 
calls either a function with a hard coded name or a name defined in the 
hook array (as you declared in ext_locaconf.php).

If you like to call other functions in your class that's fine (it's 
often better to keep your functions short).

Most of the time your hook subscriber also receives a reference to the 
calling object (often called parent object), so it's possible to call 
public functions and access public data members of that class too.

Most (if not all) hooks use either t3lib_div::getUserObj() or 
t3lib_div::callUserFunction() to call the hook subscriber(s). Take a 
look at those functions to see what they do.

[1] http://typo3.org/development/articles/how-to-use-existing-hooks/

-- 
Kind regards / met vriendelijke groet,

Jigal van Hemert.




More information about the TYPO3-dev mailing list