[TYPO3-dev] Hooks and protected class members

Jigal van Hemert jigal at xs4all.nl
Sun Nov 14 08:01:22 CET 2010


Hi,

On 14-11-2010 0:19, Ingo Renner wrote:
> Martin Kutschker wrote:
>> Generally I don't think that a hook subscriber should have access
>> to all protected members by default.
>
> agreed, usually there's a reason for that... it's called OOP and data
>  encapsulation.

And OOP knows the concept of "friend" classes, which have access to 
those members. Unfortunately PHP doesn't know that concept as I've 
written in the original message.

> So if you want to access a protected member, make sure to introduce a
>  getter and setter.

As you can find in the original message, there is such a construction 
possible with the 'magic' __get() and __set() methods.

The practical problem is that you sometimes need a solution for a 
project and you find a suitable hook that could be used. The only 
problem you find is that the data you need to read/write is not accessible.
You either have to go through the process of requesting access to that 
member by an RFC (core) or asking the extension author, waiting for a 
next release, etc. Because the project would have passed the dead line a 
long time ago the problem has already been solved by XCLASSing.

But I understood that the consensus is that the hook provider is 
completely in charge of which data is available to the hook subscriber.

Anyway, live goes on; instead of "getting hooked" I'll just keep 
XCLASSing ;-)

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