[TYPO3] Building a hook

Bernhard Kraft kraftb at kraftb.at
Sat Mar 11 00:57:47 CET 2006


tapio wrote:
> 
>> Look at the hooks in t3lib_tcemain ... they always do something like:
>>
>> $_procObj->postProcessData(...)
> 
> 
> the first is just
> 
> $hookObjectsArr = array();
>         if (is_array
> ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']))
> {
>             foreach
> ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']
> as $classRef) {
>                 $hookObjectsArr[] = &t3lib_div::getUserObj($classRef);
>             }
>         }

This is just made this way because more than one hook-method is called during this method of
t3lib_tcemain - so you wont create the hook object twice ... you create one hook object
whose key is "processDatamapClass" ....

and then search further in this method of t3lib_tcemain for $hookObjectsArr and look how it
is used.
It is traversed and for each element it is looke if there are special methods availab (preProces
postProces, etc.) and then those methods are called with special arguments.

And either you return a value by passing the variable by reference (& operator) or you simply return
a boolean value which is simpler in your case because the hook method shall just decide wheter somebody
has access to something (to say it clear: i don't really know where you would like to grant which access :)


greets,
Bernhard
-- 
----------------------------------------------------------------------
"Freiheit ist immer auch die Freiheit des Andersdenkenden"
Rosa Luxemburg, 1871 - 1919
----------------------------------------------------------------------



More information about the TYPO3-english mailing list