找回密码
 立即注册

QQ登录

只需一步,快速开始

thinkphp 3.2.3获取当前项目下所有的控制器方法名称

crx349 于 2018-8-15 15:20 [ThinkPHP 3.2] 发表在 [复制链接] [显示全部楼层] [打印] [上一主题] [下一主题]
  1. //获取所有控制器名称
  2. protected function getController($module){
  3. if(empty($module)) return null;
  4. $module_path = APP_PATH . '/' . $module . '/Controller/'; //控制器路径
  5. if(!is_dir($module_path)) return null;
  6. $module_path .= '/*.class.php';
  7. $ary_files = glob($module_path);
  8. foreach ($ary_files as $file) {
  9. if (is_dir($file)) {
  10. continue;
  11. }else {
  12. $files[] = basename($file, C('DEFAULT_C_LAYER').'.class.php');
  13. }
  14. }
  15. $i = array('Com','Qq','Shop','Payment','abc');
  16. foreach ($files as $func){
  17. if(!in_array($func, $i)){
  18. $arrr[] = $func;
  19. }
  20. }
  21. return $arrr;
  22. }
  23. //获取所有方法名称
  24. protected function getAction($controller){
  25. if(empty($controller)) return null;
  26. $con = A($controller);
  27. $functions = get_class_methods($con);
  28. //排除部分方法
  29. $inherents_functions = array(
  30. '_initialize','__construct','getActionName',
  31. 'isAjax','display','show','fetch','buildHtml','assign','__set','get',
  32. '__get','__isset','__call','error','success','ajaxReturn','redirect',
  33. '__destruct', '_empty','verify','validateUser','createSn','getpage',
  34. 'json','xml','xmlTo','theme'
  35. );
  36. foreach ($functions as $func){
  37. if(!in_array($func, $inherents_functions)){
  38. $customer_functions[] = $func;
  39. }
  40. }
  41. return $customer_functions;
  42. }


  43. //获取所有控制器下的所有方法
  44. public function abc(){


  45. $a = $this->getController('Shequapp');
  46. for ($i=0; $i <count($a) ; $i++) {
  47. $c[$a[$i]]= $this->getAction($a[$i]);
  48. }

  49. p($c);
  50. }
复制代码

本教程由无限星辰工作室CRX349独家整理和提供,转载请注明地址,谢谢。本文地址:https://www.xmspace.net/thread-639-1-1.html
无限星辰工作室  好集导航 Discuz全集下载  星辰站长网  集热爱361  一品文学  手机小游戏合集   海外空间网 星辰api  星辰支付二维码管理平台 阿里云服务器 腾讯云服务器
服务Discuz!建站|DiscuzQ配置|二开|小程序|APP|搬家|挂马清理|防护|Win/Linux环境搭建|优化|运维|
服务理念:专业 诚信 友好QQ842062626 服务项目 Q群315524225

发表于 2018-8-15 15:20:12 | 显示全部楼层 |阅读模式

回复 | 使用道具 举报

该帖共收到 0 条回复!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

美图秀

    • fastadmin 后台界面使用字段数组类型
    • Discuz!x3.5 修改标题高亮颜色
    • Discuz!x3.5 应用中心 下载应用一直下载中
    • 帖子定时显示
    • 论坛辅助审核
拖动客服框
Online Service
点击这里给我发消息
点击这里联系我们
微信扫一扫
在线客服
快速回复 返回顶部 返回列表