#55: ZendFramework PluginProxy can't be called without prepending "echo"
Issue revisions
- new by SunFire at 2010-J-26 19:39
- closed by Jordi Boggiano at 2010-J-26 20:42
| Type | |
|---|---|
| State | |
| Priority | |
| Resolution | |
| Assigned to | Nobody |
| Scheduled for | |
| Affected versions | |
| Affected components | Core |
| Last change | Tuesday 26 January 2010 20:42:08 UTC by Jordi Boggiano |
Short description
When you use a ZendFramework View Helper via the PluginProxy the resulting code will always be prepended with a "echo". The problem is that certain scenarios there should not be an "echo" because you don't want to automatically call toString() on the proxied view helper. A good example on how this can go wrong is the ZendView HeadStyle Helper which is called twice but only one of the times an echo should be prepended or the resulting stylesheet will appear twice in the output as well.
Environment
ZendServer CE 4.0.6 PHP 5.2.11
Steps to reproduce
[master.tpl] <head> {headStyle()} //here it should prepend the echo in order to create stylesheet elements for all stacked CSS files </head> {block "content"}
[view.tpl] {extends "master.tpl"} {block "content"} {headLink()->appendStylesheet('css/blog.css')} //here it should not add an echo because you only want to put the css file on the stack {/block}
Expected behavior
[ouput] <head> <link href="css/blog.css" rel="stylesheet" /> </head>
Actual behavior
[ouput] <head> <link href="css/blog.css" rel="stylesheet" /> </head> <link href="css/blog.css" rel="stylesheet" />
So it would be nice if somehow it could be controlled if there was an echo prepended to a PluginProxy call or not.
Jordi Boggiano at Tuesday 26 January 2010 20:42:08 UTC
This is possible through the "do" function, I'm sorry but it can not be automated since Dwoo can't know what you are trying to do.
See the do wiki page.
SunFire at Wednesday 27 January 2010 10:09:57 UTC
Ok, "do" would work in some cases. Unfortunately the outlined example was a simplification and I need to have access to scoped variables. For now I use something like this to workaround:
{do headLink()->appendStylesheet($this->scope["stylesheetUri"])}
If there maybe a "cleaner" way to do this?
Jordi Boggiano at Wednesday 27 January 2010 10:12:43 UTC
Hmm, how come you need to call $this->scope ?
Doesn't {do headLink()->appendStylesheet($stylesheetUri)} work ?
SunFire at Thursday 28 January 2010 10:15:22 UTC
No, unfortunately it doesn't. I get this when I try to do so: Undefined variable: stylesheetUri
Jordi Boggiano at Thursday 28 January 2010 10:45:51 UTC
Okay, I think this has been fixed in revision #330. Could you please check if it works when you use a svn checkout from http://svn.dwoo.org/branches/1.1/lib or http://svn.dwoo.org/trunk/lib ?
SunFire at Thursday 28 January 2010 12:49:00 UTC
Just verified that your fix does work. Thanks
Jordi Boggiano at Thursday 28 January 2010 13:03:35 UTC
Alright good, I'll really try to push a new release soon, it's way overdue.