Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit baaeee3

Browse files
committed
Make sure renderer is PhpRenderer before getting plugin
Plus some typehinting fixes
1 parent 1709b4f commit baaeee3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/ZendViewRenderer.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @see https://github.com/zendframework/zend-expressive-zendviewrenderer for the canonical source repository
4-
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (https://www.zend.com)
4+
* @copyright Copyright (c) 2015-2019 Zend Technologies USA Inc. (https://www.zend.com)
55
* @license https://github.com/zendframework/zend-expressive-zendviewrenderer/blob/master/LICENSE.md New BSD License
66
*/
77

@@ -44,7 +44,7 @@ class ZendViewRenderer implements TemplateRendererInterface
4444
use DefaultParamsTrait;
4545

4646
/**
47-
* @var ViewModel
47+
* @var null|ModelInterface
4848
*/
4949
private $layout;
5050

@@ -207,6 +207,7 @@ private function renderModel(
207207
$root = $model;
208208
}
209209

210+
/** @var ModelInterface $child */
210211
foreach ($model as $child) {
211212
if ($child->terminate()) {
212213
throw new Exception\RenderingException('Cannot render; encountered a child marked terminal');
@@ -219,7 +220,8 @@ private function renderModel(
219220

220221
$child = $this->mergeViewModel($child->getTemplate(), $child);
221222

222-
if ($child !== $root) {
223+
if ($renderer instanceof PhpRenderer && $child !== $root) {
224+
/** @var Helper\ViewModel $viewModelHelper */
223225
$viewModelHelper = $renderer->plugin(Helper\ViewModel::class);
224226
$viewModelHelper->setRoot($root);
225227
}

0 commit comments

Comments
 (0)