Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Zend\View\Renderer\PhpRenderer properties unaccessable #4385

h3lpd3sk opened this Issue · 4 comments

2 participants


For a recursive render I'd ideally need the current template from the PhpRenderer.
However there's no method for accessing the __template property.
Since it's private even there's no point in extending the PhpRenderer either.

Think this and perhaps other properties should be accessible through methods or overloading.

Not sure what the philosophy behind this is, sure there's one I might be overlooking?

Work around with ReflectionObject isn't really a good solution but possible...

$reflection = new ReflectionObject($this);
$property = $reflection->getProperty('__template');
$template = $property->getValue($this);

Template name, or template file? The latter can be accessed within the template itself using the __FILE__ magic constant...


FILE gives full path, $__template holds relative.

So they are not the same.
Would need to parse FILE in order to get same, not sure if there's a real re-usable logic in that?
Would make sense to just be able to get it from Renderer
Not even sure what happens with Map Strategy?


$reflection = new ReflectionObject($this);
$property   = $reflection->getProperty('__template');
$template   = $property->getValue($this);

foreach($items as $item){
     //render recursive
     echo $this->partial($template /* this is what I need*/, array('items' => $item->getChildren()));

Is there any reason why this particular variable isn't available?


Is there any reason why this particular variable isn't available?

Nobody's ever requested it before. :)

Thanks for the use case example -- it makes the request much more clear.


You're welcome,

Would have made the required code changes and a pull request if I knew howto.
Can't be more then a few lines of code...
Just getting out of svn :-)

So now what?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.