(Yaf >=1.0.0)
Yaf_Plugin_Abstract::preResponse — Hook before the response is sent
$request, Yaf_Response_Abstract $response): voidThis 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.
requestThe Yaf_Request_Abstract instance being dispatched.
responseThe Yaf_Response_Abstract instance.
No value is returned.
Example #1 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());
}
}
?>