【发布时间】:2015-03-07 13:50:20
【问题描述】:
我想在每次在类中使用方法(不管是私有的、受保护的还是公共的)之前和之后添加一些逻辑。
例如:
class Service
{
function test1() {
Log:start(__METHOD__);
someLogicInThere(); ....
Log:end(__METHOD__);
}
function test2() {
Log:start(__METHOD__);
someLogicInThere(); ....
Log:end(__METHOD__);
}
...
}
我的想法是最终有这样的东西:
/**
* @LogDecorate
*/
class Service
{
function test1() {
someLogicInThere();
}
function test2() {
someLogicInThere();
}
...
}
使用注释并不重要。有什么办法吗?
【问题讨论】:
标签: php design-patterns decorator