Closed longhtml closed 5 years ago
<?php
class Swing { public function index() { echo 'yes'; } }
class Swing111 { public function index() { echo '111 yes'; } }
Xaop::addBeforeAop('Swing*', "index", function(){ echo '_before'; });
$swing = new Swing(); $swing->index();
$swing = new Swing111(); $swing->index();
$api = new Swing111(); $action = 'index'; $data = call_user_func(array($api, $action));
// output: _before yes _before 111 yes _before 111 yes
例如:Api_1, Api_2 ... 类, 里面一个方法 call()。
class Api_1 { public function call() }
class Api_2 { public function call() }
是否支持这样使用?
// 注入前置AOP Xaop::addBeforeAop("Api_*", "call", function(){ echo 'call _before
'; });
针对Api_* 各个类, 对call()方法切入。