[TYPO3-dev] Hooks and protected class members
Jigal van Hemert
jigal at xs4all.nl
Wed Sep 22 15:04:25 CEST 2010
Hi,
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.
In several places I found that my hook functions could not use all data
members inside the 'parent object' because they are protected.
PHP does not know the concept of 'friend' classes, but there is a
solution available with which involves __get and __set functions [1].
We could try to set up such a construction where the class which
provides the hook somehow (with the help of t3lib_div::makeInstance()
perhaps) adds the class with the hook function to it's list of friends.
This way the hook functions can access protected members through the
__get and __set.
Opinions?
[1] http://bugs.php.net/34044
--
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