php8.5
Home/ Manual/ yaf / yaf_plugin_abstract/ Yaf_Plugin_Abstract::dispatchLoopShutdown

Yaf_Plugin_Abstract::dispatchLoopShutdown

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Hook after dispatch loop

Description

Yaf_Plugin_Abstract::dispatchLoopShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response): void

This hook is triggered once, after the dispatch loop has finished and all actions have been executed, but before the response is sent to the client. It is usually used for logging or cleanup.

Parameters

request

The Yaf_Request_Abstract instance being dispatched.

response

The Yaf_Response_Abstract instance.

Return Values

No value is returned.

Examples

Yaf_Plugin_Abstract::dispatchLoopShutdown example

php
<?php
class AccessLogPlugin extends Yaf_Plugin_Abstract
{
    public function dispatchLoopShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
    {
        /* last hook before the response is sent: write an
         * access log entry */
        error_log(sprintf(
            "[%s] %s dispatched to %s/%s",
            date("c"),
            $request->getRequestUri(),
            $request->getControllerName(),
            $request->getActionName()
        ));
    }
}

/* plugins are registered in the bootstrap */
class Bootstrap extends Yaf_Bootstrap_Abstract
{
    public function _initPlugin(Yaf_Dispatcher $dispatcher)
    {
        $dispatcher->registerPlugin(new AccessLogPlugin());
    }
}
?>

See Also

  • Yaf_Plugin_Abstract::routerStartup
  • Yaf_Plugin_Abstract::routerShutdown
  • Yaf_Plugin_Abstract::dispatchLoopStartup
  • Yaf_Plugin_Abstract::preDispatch
  • Yaf_Plugin_Abstract::postDispatch
  • Yaf_Plugin_Abstract::preResponse

Source: reference/yaf/yaf_plugin_abstract/dispatchloopshutdown.xml · from the official PHP manual (php/doc-en)