[TYPO3-dev] Hooks and protected class members

Jigal van Hemert jigal at xs4all.nl
Thu Sep 23 11:03:15 CEST 2010


Hi,

On 23-9-2010 8:47, Martin Kutschker wrote:
> Am 22.09.2010 15:04, schrieb Jigal van Hemert:
>> We're both promoting the use of hooks for modifying functionality
>> and the use of protected class members if they need not be exposed
>> in the API.
>>
>> Opinions?
>
> Add those protected members, if it makes sense to the parameter list
> of the hook.

That could become quite a big list (including the members in the parent 
class(es)).

> Generally I don't think that a hook subscriber should have access to
> all protected members by default.

Hooks are meant to be preferred over XCLASSing. With all the protected 
members which are introduced in recent RFCs the possibilities for hook 
subscribers to do anything meaningful become really restricted.

An XCLASSed version of a function has full access to the private and 
public class members where a hook subscriber can only use the public 
members. It seems to me that this makes it less attractive to use a 
hook. Example:

felogin has a hook 'postProcContent' in the main() method. It also has 
protected class members for the isUserLoggedIn state and the logintype. 
If you want to do something in the hook subscriber which depends on 
either of those you have to look up where they got their values and use 
a local version of those variables.

I can't even access the template to process a subtemplate I added to my 
custom version of the template.

Class members of the parent class tslib_pibase are accessible (public by 
default), but refactoring may turn many of those into protected members...

-- 
Kind regards / met vriendelijke groet,

Jigal van Hemert
skype:jigal.van.hemert
msn: jigal at xs4all.nl
http://twitter.com/jigalvh




More information about the TYPO3-dev mailing list