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

Commit 392794d

Browse files
committed
Merge branch 'hotfix/25' into develop
Forward port #25
2 parents 82c537d + a1da77c commit 392794d

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ All notable changes to this project will be documented in this file, in reverse
4848

4949
### Fixed
5050

51-
- Nothing.
51+
- [#25](https://github.com/zendframework/zend-view/pull/25) updates
52+
`PhpRenderer::render()` to no longer lazy-instantiate a `FilterChain`;
53+
content filtering is now only done if a `FitlerChain` is already
54+
injected in the renderer.
5255

5356
## 2.5.2 - 2015-06-16
5457

src/Renderer/PhpRenderer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,11 @@ public function render($nameOrModel, $values = null)
516516

517517
$this->setVars(array_pop($this->__varsCache));
518518

519-
return $this->getFilterChain()->filter($this->__content); // filter output
519+
if ($this->__filterChain instanceof FilterChain) {
520+
return $this->__filterChain->filter($this->__content); // filter output
521+
}
522+
523+
return $this->__content;
520524
}
521525

522526
/**

test/PhpRendererTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,4 +464,14 @@ public function testSharedInstanceHelper()
464464
$this->assertEquals(2, $this->renderer->sharedinstance());
465465
$this->assertEquals(3, $this->renderer->sharedinstance());
466466
}
467+
468+
public function testDoesNotCallFilterChainIfNoFilterChainWasSet()
469+
{
470+
$this->renderer->resolver()->addPath(__DIR__ . '/_templates');
471+
472+
$result = $this->renderer->render('empty.phtml');
473+
474+
$this->assertContains('Empty view', $result);
475+
$this->assertAttributeEmpty('__filterChain', $this->renderer);
476+
}
467477
}

0 commit comments

Comments
 (0)