(Yaf >=1.0.0)
Yaf_Plugin_Abstract::dispatchLoopStartup — 分发循环之前的钩子
$request, Yaf_Response_Abstract $response): void这个钩子会在分发循环开始、视图引擎初始化之前触发一次。
request正在被分发的 Yaf_Request_Abstract 实例。
response没有返回值。
示例 #1 Yaf_Plugin_Abstract::dispatchLoopStartup() 示例
<?php
class BenchmarkPlugin extends Yaf_Plugin_Abstract
{
public function dispatchLoopStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
{
/* 此时视图引擎尚未初始化,因此这个钩子是
* 开始整个请求计时的好位置 */
Yaf_Registry::set("request_start", microtime(true));
}
}
/* 插件在引导(bootstrap)中注册 */
class Bootstrap extends Yaf_Bootstrap_Abstract
{
public function _initPlugin(Yaf_Dispatcher $dispatcher)
{
$dispatcher->registerPlugin(new BenchmarkPlugin());
}
}
?>