[TYPO3-dev] Hooks and protected class members

Xavier Perseguers typo3 at perseguers.ch
Thu Sep 23 13:28:01 CEST 2010


Hi,

>>> 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.

Me neither.

> 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

Not private, protected.

> 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.

Then getters for those attribute should be added.

> 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...

This means they never were intended to be used from outside. Hooks have 
been given, at least at the beginning, the list of parameters that may 
be useful within it. If some property is missing, you should either ask 
to provide such information or we should find out whether a getter would 
be worth.

Xavier




More information about the TYPO3-dev mailing list