Feature/render listener #2959

merged 15 commits into from Nov 13, 2012


None yet
5 participants

weierophinney commented Nov 13, 2012

This request builds on #2812, which is intended as a solution for #2528. The idea is to allow catching renderer exceptions, and triggering an additional event when one is detected.

The main differences between this PR and #2812 are:

  • Moves the exception handling into the DefaultRenderingStrategy. This better mirrors how the route and dispatch exceptions are handled, and keeps the Application class clean.
  • Moved the clearChildren() definition out of ModelInterface and into ClearableModelInterface in order to remove a BC break. ViewModel implements this by default. (I also added methods for clearVariables() and clearOptiosn() to the new interface.)
  • Fixed a testing issue created by the fact that exceptions in rendering are now actually handled by the PhpRenderer.

radnan and others added some commits Oct 19, 2012

@radnan radnan Catch render exceptions and trigger dispatch error
Catch exceptions thrown when EVENT_RENDER is triggered, clean up all output, trigger EVENT_DISPATCH_ERROR, and finally re-trigger EVENT_RENDER
Rafi Catch exception, cleanup, and re-throw when rendering model 743a06c
Rafi Clear child models before injecting in case of error 257941f
Rafi clear out child models 4f1d1d3
Rafi Implemented clearChildren() 682137e
@radnan radnan Opening brace on same-line c89b5e1
@radnan radnan Trigger render_error event b98ca20
@radnan radnan Added render.error event constant 5091be1
@radnan radnan Attach to render.error 2b5b708
@radnan radnan Attach to 'render.error' 50a5f39
@radnan radnan Removed unnecessary cleanup 15e8718
@weierophinney weierophinney Merge branch 'render-exceptions' of git://github.com/radnan/zf2 into …
@weierophinney weierophinney [#2812][#2528] Move exception handling into DefaultRenderingStrategy
- For symmetry with DispatchListener and RouteListener, moved the
  exception handling out of Application and into
- Reviewed Zend\Mvc\View\Console\DefaultRenderingStrategy to see if
  exception handling was necessary; it wasn't, but cleaned up a few CS
  issues in the process.
@weierophinney weierophinney [#2812][#2528] Fix newly failing test
- Test now had an expectation that was no longer necessary: that the
  output would continue to be captured and present. Since the
  PhpRenderer now catches exceptions and re-throws, the output buffering
  is handled slightly differently in exceptional circumstances.
@weierophinney weierophinney [#2812][#2528] Moved clearChildren into separate interface
- Cannot add methods to existing interfaces; breaks BC
- Created ClearableModelInterface with clearChildren(), and also added
  clearVariables() and clearOptions().
- ViewModel implements ModelInterface and ClearableModelInterface.
- InjectViewModelListener now tests for ClearableModelInterface before
  attempting to clearChildren()

akrabat commented Nov 13, 2012

Reviewed code - looks sane and unit tests pass here too.

akrabat merged commit 43465cc into zendframework:develop Nov 13, 2012


basz commented on fee0bad Nov 14, 2012

referencing zendframework#2964

I've created a custom form and am trying to render it into a view. However, the form has a bug inside it. DefaultRenderingStrategy::render() is catching it on line 131 and my app subsequently whitescreens and I cannot understand why. Is it related to this merge?


radnan commented Jan 9, 2013

@blockjon yes it is related to this. i've submitted a pr for the fix in #3385.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment