(Yaf >=1.0.0)
Yaf_Plugin_Abstract::dispatchLoopShutdown — 分发循环之后的钩子
$request, Yaf_Response_Abstract $response): void这个钩子会在分发循环结束、所有动作执行完毕之后触发一次,且在响应发送给客户端之前。通常用于记录日志或清理工作。
request正在被分发的 Yaf_Request_Abstract 实例。
response没有返回值。
示例 #1 Yaf_Plugin_Abstract::dispatchLoopShutdown() 示例
<?php
class AccessLogPlugin extends Yaf_Plugin_Abstract
{
public function dispatchLoopShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
{
/* 这是响应发送之前的最后一个钩子:
* 写一条访问日志 */
error_log(sprintf(
"[%s] %s dispatched to %s/%s",
date("c"),
$request->getRequestUri(),
$request->getControllerName(),
$request->getActionName()
));
}
}
/* 插件在引导(bootstrap)中注册 */
class Bootstrap extends Yaf_Bootstrap_Abstract
{
public function _initPlugin(Yaf_Dispatcher $dispatcher)
{
$dispatcher->registerPlugin(new AccessLogPlugin());
}
}
?>