Yaf_Plugin_Abstract::postDispatch
PHP function
Edit on GitHub ✎
(Yaf >=1.0.0)
Hook after each dispatch
Description
Yaf_Plugin_Abstract::postDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response): void
This hook is triggered after each dispatch iteration finishes, i.e. after the action has been executed. Like Yaf_Plugin_Abstract::preDispatch, it may be called more than once per request.
Parameters
requestThe
Yaf_Request_Abstractinstance being dispatched.responseThe
Yaf_Response_Abstractinstance.
Return Values
No value is returned.
Examples
Yaf_Plugin_Abstract::postDispatch example
php
<?php
class BenchmarkPlugin extends Yaf_Plugin_Abstract
{
public function postDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
{
/* the action has been executed: append some debug
* information to the response body */
$elapsed = microtime(true) - Yaf_Registry::get("request_start");
$response->appendBody(sprintf(
"\n<!-- rendered in %.3f seconds -->",
$elapsed
));
}
}
/* plugins are registered in the bootstrap */
class Bootstrap extends Yaf_Bootstrap_Abstract
{
public function _initPlugin(Yaf_Dispatcher $dispatcher)
{
$dispatcher->registerPlugin(new BenchmarkPlugin());
}
}
?>See Also
Yaf_Plugin_Abstract::routerStartupYaf_Plugin_Abstract::routerShutdownYaf_Plugin_Abstract::dispatchLoopStartupYaf_Plugin_Abstract::preDispatchYaf_Plugin_Abstract::dispatchLoopShutdownYaf_Plugin_Abstract::preResponse