ZF-10042: Variables assignment option for Zend_View
Description
Please add an option to Zend_View allowing assignment of view variables when Zend_View is constructed.
For example:
$view = new View(
array(
'assign' => array(
'keywords' => 'zend framework, php, framework'
'pragma' => 'no-cache',
'footertext' => 'MyProject (C) 2010',
'somedata' => array('foo', 'bar')
)
)
);
This would allow passing variables direct from configuration (Zend_Application_Resource_View) to Zend_View, like:
resources.view.assign.keywords = "zend framework, php, framework"
resources.view.assign.pragma = "no-cache"
resources.view.assign.footertext = "MyProject (C) 2010"
resources.view.assign.somedata[] = "foo bar"
Comments
Posted by Kim Blomqvist (kblomqvist) on 2011-04-28T17:27:58.000+0000
Patch attached.
Posted by Kim Blomqvist (kblomqvist) on 2011-04-28T18:40:34.000+0000
Attach the right file, ignore View.php
Posted by Kim Blomqvist (kblomqvist) on 2011-04-29T13:48:35.000+0000
Adding alternative way to solve this improvement as it was suggested in the issue description. (View.php.patch-alt)
Posted by Matthew Weier O'Phinney (matthew) on 2011-05-03T20:54:07.000+0000
Kim -- the patch can be made simpler: simply pass $config['assign'] to $this->assign() if it's set and an array. :)
Posted by Ralph Schindler (ralph) on 2011-05-04T03:32:18.000+0000
Fixed in trunk at r23991 and in release branch 1.11 at r23992