-- Jaka Jančar <[EMAIL PROTECTED]> wrote
(on Saturday, 23 August 2008, 11:47 PM +0200):
> Hello!
>
> In Zend_Form_Decorator_ViewHelper::render() the following is being done:
>
> ---
> if (method_exists($element, 'getMultiOptions')) {
> $element->getMultiOptions();
> }
>
> [...]
>
> $elementContent = $view->$helper($name, $value, $attribs, $element-
> >options);
> ---
>
> I'm modifying the class heavily and am a bit puzzled by this, since I
> don't understand it.
>
> Is there a reason why getMultiOptions() is getting called earlier and
> later the property is accessed directly? So basically, why the options
> aren't just accessed through the getter like:
>
> ---
> $options = method_exists($element, 'getMultiOptions') ? $element-
> >getMultiOptions() : null;
> $elementContent = $view->$helper($name, $value, $attribs, $options);
> ---
Some elements don't aggregate the multi options into the $options
property until getMultiOptions() is called, so this ensures they are
set. Additionally, __get() returns null if a property is not set, which
is why we call $element->options when calling the view helper.
You're right though -- it may need to be refactored. For now, though, it
gets the job done.
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend Framework | http://framework.zend.com/