Yaf_Plugin_Abstract::preResponse
(Yaf >=1.0.0)
Hook before the response is sent
Description
This hook is intended to be triggered before the response is sent to the client.
As of this version this hook is never called: it is registered on Yaf_Plugin_Abstract but not wired into the dispatch flow. Overriding it has no effect.
Parameters
requestThe
Yaf_Request_Abstractinstance being dispatched.responseThe
Yaf_Response_Abstractinstance.
Return Values
No value is returned.
Examples
Yaf_Plugin_Abstract::preResponse example
<?php
class MinifyPlugin extends Yaf_Plugin_Abstract
{
public function preResponse(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
{
/* meant to minify the body right before it is sent; note
* that, as of this version, this hook is never actually
* called */
$response->setBody(
preg_replace("/>\s+</", "><", $response->getBody())
);
}
}
/* plugins are registered in the bootstrap */
class Bootstrap extends Yaf_Bootstrap_Abstract
{
public function _initPlugin(Yaf_Dispatcher $dispatcher)
{
$dispatcher->registerPlugin(new MinifyPlugin());
}
}
?>See Also
Yaf_Plugin_Abstract::routerStartupYaf_Plugin_Abstract::routerShutdownYaf_Plugin_Abstract::dispatchLoopStartupYaf_Plugin_Abstract::preDispatchYaf_Plugin_Abstract::postDispatchYaf_Plugin_Abstract::dispatchLoopShutdown