Skip to content

Commit

Permalink
Adding new callbacks into View.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 18, 2011
1 parent 3fe7956 commit c49e261
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/Cake/Test/Case/View/ViewTest.php
Expand Up @@ -586,11 +586,19 @@ public function testHelperCallbackTriggering() {
$View->Helpers->expects($this->at(0))->method('trigger')
->with('beforeRender', $this->anything());
$View->Helpers->expects($this->at(1))->method('trigger')
->with('beforeRenderFile', $this->anything());
$View->Helpers->expects($this->at(2))->method('trigger')
->with('afterRenderFile', $this->anything());
$View->Helpers->expects($this->at(3))->method('trigger')
->with('afterRender', $this->anything());

$View->Helpers->expects($this->at(2))->method('trigger')
$View->Helpers->expects($this->at(4))->method('trigger')
->with('beforeLayout', $this->anything());
$View->Helpers->expects($this->at(3))->method('trigger')
$View->Helpers->expects($this->at(5))->method('trigger')
->with('beforeRenderFile', $this->anything());
$View->Helpers->expects($this->at(6))->method('trigger')
->with('afterRenderFile', $this->anything());
$View->Helpers->expects($this->at(7))->method('trigger')
->with('afterLayout', $this->anything());

$View->render('index');
Expand Down
3 changes: 3 additions & 0 deletions lib/Cake/View/View.php
Expand Up @@ -754,7 +754,10 @@ protected function _render($viewFile, $data = array()) {
$data = $this->viewVars;
}
$this->_current = $viewFile;

$this->Helpers->trigger('beforeRenderFile', array($viewFile));
$content = $this->_evaluate($viewFile, $data);
$this->Helpers->trigger('afterRenderFile', array($viewFile));

if (isset($this->_parents[$viewFile])) {
$this->_stack[] = $this->fetch('content');
Expand Down

0 comments on commit c49e261

Please sign in to comment.