[Typo3-dev] Hooks...
Robert Lemke
robert at typo3.org
Mon Dec 13 13:33:23 CET 2004
Hi Julle,
Christian Jul Jensen wrote:
> In roberts tutorial I read something like 'some like the callUserObj
> way better because it follows some fancy design pattern', this must
> have to be singleton.
yes it is.
> Now the thing is, you can also call objects and have them instantiated
> as singletons with the callUserFunction, in fact the only thing I can
> see that is not equal or better with the callUserFunction is that you
> can not define a clear signature of the method called from within the
> hook, but have to pass everything as an array.
yes, that is the main difference.
> On the other hand you have the benefit of not having to specify the
> methodname in the hook, thereby providing a higher level of
> transparency, in fact the client can decide if it wants to call a
> function or method on an object.
using the callUserObj way let's you choose a function / method name,
getUserObj works with predefined method names which are expected to exist
in your class.
Generally it is a good idea to user the getUserObj way if you have more than
one function you need to provide for the hook, because you only have to
specify your class name once and all functions of that hook will be used
automatically.
I prefer the getUserObj way where it makes sense, but sometimes the
callUserFunction way is quite more flexible.
> If not I think we should stick to one way of doing hooks, it's not
> like we donøt have enough complexy in TYPO3 already, in fact I would
> also like to see some kind of abstraction like
> t3lib_extmgm::registerHook()
I think it is good to have both ways, maybe we have to give better
explanations how both work for the implementor of a hook. I didn't think
much about an abstraction function, but at the first glance I can't imagine
how that function would look like. Do you?
--
robert
More information about the TYPO3-dev
mailing list