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

Commit 5f6bdee

Browse files
committed
optionally disable layout rendering
1 parent ca34ef0 commit 5f6bdee

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/ZendViewRenderer.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ public function render($name, $params = [])
127127
? $this->mergeViewModel($name, $params)
128128
: $this->createModel($name, $params);
129129

130-
$viewModel = $this->prepareLayout($viewModel);
130+
$useLayout = false !== $viewModel->getVariable('layout', null);
131+
if ($useLayout) {
132+
$viewModel = $this->prepareLayout($viewModel);
133+
}
131134

132135
return $this->renderModel($viewModel, $this->renderer);
133136
}
@@ -319,16 +322,16 @@ private function mergeViewModel($name, ModelInterface $model)
319322
*/
320323
private function prepareLayout(ModelInterface $viewModel)
321324
{
322-
$layout = $this->layout ? clone $this->layout : null;
323-
324-
$providedLayout = $viewModel->getVariable('layout', false);
325+
$providedLayout = $viewModel->getVariable('layout', null);
325326
if (is_string($providedLayout) && ! empty($providedLayout)) {
326327
$layout = new ViewModel();
327328
$layout->setTemplate($providedLayout);
328329
$viewModel->setVariable('layout', null);
329330
} elseif ($providedLayout instanceof ModelInterface) {
330331
$layout = $providedLayout;
331332
$viewModel->setVariable('layout', null);
333+
} else {
334+
$layout = $this->layout ? clone $this->layout : null;
332335
}
333336

334337
if ($layout) {

0 commit comments

Comments
 (0)