i am reading zend framework docs on zend view partials
If your model is an object, you may
want to have it passed as an object to
the partial script, instead of
serializing it to an array of
variables. You can do this by setting
the ‘objectKey’ property of the
appropriate helper:// Tell partial to pass objects as 'model' variable $view->partial()->setObjectKey('model');
but what does this do. when do i use it and how.
I’m not 100% positive on this, but from what I can tell by looking at the source and documentation is that standard behavior for rendering a partial is that values are passed into it in the form of an associative array. This allows the values to be bound to variables using array keys.
If you pass an object as the third parameter, (ie,
partial('partial.phtml', $myobject);), Zend_View_Partial will automatically serialize that object in an associative array, either by a custom implementation oftoArray()or it will just grab the public properties viaget_object_vars().However, if you want to pass the whole object, as an object, you need to set the array key that gets transformed into a variable for the partial to reference.
What benefits this approach has over
partial('partial.phtml', array( 'myobject' => $myobject), I’m not sure. Or I could be interpreting the documentation wrong.