Yaf_Plugin_Abstract::preResponse

(Yaf >=1.0.0)

Yaf_Plugin_Abstract::preResponseHook before the response is sent

Description

public function Yaf_Plugin_Abstract::preResponse(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response): void

This hook is intended to be triggered before the response is sent to the client.

Warning

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

request

The Yaf_Request_Abstract instance being dispatched.

response

The Yaf_Response_Abstract instance.

Return Values

No value is returned.

Examples

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());
    }
}
?>

See Also

add a note

User Contributed Notes

There are no user contributed notes for this page.