public function ceshi()
{
//获取所有控制器
$controllers = getControllers('../application/admin/controller');
//结果:
// array (size=13)
// 0 => string 'Admin' (length=5)
// 1 => string 'Article' (length=7)
// 2 => string 'Config' (length=6)
// 3 => string 'Goods' (length=5)
// 4 => string 'Index' (length=5)
// 5 => string 'Login' (length=5)
// 6 => string 'Menu' (length=4)
// 7 => string 'Mysql' (length=5)
// 8 => string 'Order' (length=5)
// 9 => string 'Other' (length=5)
// 10 => string 'Upload' (length=6)
// 11 => string 'User' (length=4)
// 12 => string 'Wechat' (length=6)
//下面是获取Index控制中你定义的方法,在mobadmin的应用场景中$control由前端传入,这样就能够达到我选择某个一个控制器的时候,就会输出这个控制中定义的方法。
$control = 'Index';
$actions = getActions('app\admin\controller' . '\\' . $control);
//结果:
// array (size=3)
// 0 => string 'index' (length=5)
// 1 => string 'welcome' (length=7)
// 2 => string 'ceshi' (length=5)
//系统中所有控制的方法怎么获取呢?遍历所有控制器就可以。
$controllers = getControllers('../application/admin/controller');
$actionsAll = [];
foreach( $controllers as $key=>$value) {
$actions[$value] = get_class_methods('app\admin\controller' . '\\' . $value);
}
//结果:
// 'Admin' =>
// array (size=15)
// 0 => string '__construct' (length=11)
// 1 => string '_initialize' (length=11)
// 2 => string '_empty' (length=6)
// 3 => string 'beforeAction' (length=12)
// 4 => string 'fetch' (length=5)
// 5 => string 'display' (length=7)
// 6 => string 'assign' (length=6)
// 7 => string 'engine' (length=6)
// 8 => string 'validateFailException' (length=21)
// 9 => string 'validate' (length=8)
// 10 => string 'success' (length=7)
// 11 => string 'error' (length=5)
// 12 => string 'result' (length=6)
// 13 => string 'redirect' (length=8)
// 14 => string 'getResponseType' (length=15)
// 'Article' =>
// array (size=18)
// 0 => string 'index' (length=5)
// 1 => string 'category' (length=8)
// 2 => string 'comment' (length=7)
// 3 => string '__construct' (length=11)
// 4 => string '_initialize' (length=11)
// 5 => string '_empty' (length=6)
// 6 => string 'beforeAction' (length=12)
// 7 => string 'fetch' (length=5)
// 8 => string 'display' (length=7)
// 9 => string 'assign' (length=6)
// 10 => string 'engine' (length=6)
// 11 => string 'validateFailException' (length=21)
// 12 => string 'validate' (length=8)
// 13 => string 'success' (length=7)
// 14 => string 'error' (length=5)
// 15 => string 'result' (length=6)
// 16 => string 'redirect' (length=8)
// 17 => string 'getResponseType' (length=15)
}