1

Hi I would like to call a method at the end of a page generation using Zend Framework. How to do this?

I am using Doctrine2 + ZF. The EntityManager has a flush method, which should in the common cases only be called at the end of the page generation. Is there a hook or a destructor emulation in Zend Framework? 2

Jakob Alexander Eichler
  • 2,988
  • 3
  • 33
  • 49
  • Ok recently this: http://stackoverflow.com/questions/2253170/zend-framework-last-code-to-execute-before-layout-is-rendered helped me more than the answers here. I had to overwrite postDispatch() but maybe I am going to change this, to be able to display an error message if an error on $em->flush() occours. – Jakob Alexander Eichler Mar 17 '11 at 23:58

2 Answers2

4

Use a controller plugin. I assume the dispatchLoopShutdown is what you need.

erenon
  • 18,838
  • 2
  • 61
  • 93
0

Why just don't use your own function?

call register_shutdown_function(); and the passed function will be executed at the end of the script

dynamic
  • 46,985
  • 55
  • 154
  • 231