Re: HTML_QuickForm2_Renderer: ArrayAccess
| From: | Alexey Borzov | Date: | Wed, 05 May 2010 15:47:24 +0000 |
| Subject: | Re: HTML_QuickForm2_Renderer: ArrayAccess | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-30512@lists.php.net to get a copy of this message | ||
Hi Brett,
On 04.05.2010 3:56, Brett Bieber wrote:
I don't think implementing all the gazillion SPL interfaces (Iterator, Countable, etc) makes sense, while proxying __get() / __set() and friends may indeed be useful. Of course that means having to write $renderer->foo rather than $renderer['foo'] but I don't see a huge problem here. Thanks for an example!Using my own renderer, I wanted to implement ArrayAccess to get easy access to elements by IDs (see my last mail, "HTML_QuickForm2_Renderer_Array: Element IDs as array key?") in my templates. Unfortunately, the rendering proxy tunnels every method calls and thus prevents usage of ArrayAccess which gets not tunneled. Does someone know how I could get array access working despite the proxy? I cannot instantiate my renderer without the factory since I want to use renderer plugins.I think the proxy should implement these methods accordingly, so that these special interfaces such as Traversable, Countable, ArrayAccess, __toString, etc are handled as expected. I do something like this in Savant4/Savvy's templating system to perform automatic output escaping while preserving the object context. This example is by no means extensive, but accommodates the most-used interactions. http://github.com/saltybeagle/Savvy/blob/master/src/Savvy/ObjectProxy.php#L165