大部分框架是通过硬编码还实现的 比如
public function run()
{
if($this->hasEventHandler('onBeginRequest'))
$this->onBeginRequest(new CEvent($this));
$this->processRequest();
if($this->hasEventHandler('onEndRequest'))
$this->onEndRequest(new CEvent($this));
}
如果要加入其他事件,或者扩展参数,就无能为力了
怎么样才能自动实现在一个方法中 动态注入一段代码呢?
比如 function test(){
echo "orgin call";
}
在这个方法上,如何执行一段打印日志的代码,而不用修改原来的代码