//获取模块下所有的控制器和方法 public function initperm() {$modules = array('api');  //模块名称$i = 0;foreach ($modules as $module) {$all_controller = $this->getController($module);foreach ($all_controller as $controller) {$all_action = $this->getAction($module, $controller);foreach ($all_action as $action) {$controller = str_replace('Controller', '', $controller);$data[$i]['module'] = $module;$data[$i]['controller'] = $controller;$data[$i]['action'] = $action;//入库if (!empty($module) && !empty($controller) && !empty($action)) {$rule_name = $module . '/' . $controller . '/' . $action;if (!$rule) {$idata = array();$idata['module'] = strtolower($module . '/' . $controller);$idata['type'] = "1";$idata['name'] = strtolower($rule_name);$idata['title'] = "";$idata['regex'] = "";$idata['status'] = "1";}}$i++;}}}return $data;
//      echo '<pre>';
//      print_r($data);
//      echo '</pre>';}//获取所有控制器名称private function getController($module) {if (empty($module)) {return null;}$module_path = APP_PATH . '/' . $module . '/controller/';  //控制器路径if (!is_dir($module_path)) {return null;}$module_path .= '/*.php';$ary_files = glob($module_path);foreach ($ary_files as $file) {if (is_dir($file)) {continue;} else {$files[] = basename($file, '.php');}}return $files;}//获取所有方法名称protected function getAction($module, $controller) {if (empty($controller)) {return null;}$customer_functions = [];$file = APP_PATH . $module . '/controller/' . $controller . '.php';if (file_exists($file)) {$content = file_get_contents($file);preg_match_all("/.*?public.*?function(.*?)\(.*?\)/i", $content, $matches);$functions = $matches[1];//排除部分方法$inherents_functions = array('_initialize', '__construct', 'getActionName', 'isAjax', 'display', 'show', 'fetch', 'buildHtml', 'assign', '__set', 'get', '__get', '__isset', '__call', 'error', 'success', 'ajaxReturn', 'redirect', '__destruct', '_empty');foreach ($functions as $func) {$func = trim($func);if (!in_array($func, $inherents_functions)) {$customer_functions[] = $func;}}return $customer_functions;} else {//            \ticky\Log::record('is not file ' . $file, Log::INFO);return false;}return null;}

获取thinkph5下控制器和方法名相关推荐

  1. php返回类中方法,php如何获取类中所有的方法名

    php获取类中所有的方法名的方法:可以利用[get_class_methods()]函数来获取,[get_class_methods()]函数可以返回指定类中所有的方法名,并且会将方法名保存到数组中. ...

  2. python 获取当前class名和方法名

    代码如下: # coding=utf-8import sys class Hello():def hello(self):print('the name of method is ## {} ##'. ...

  3. 【转】获取命名空间、类名、方法名

    string str = "";//取得当前方法命名空间str += "命名空间名:" + System.Reflection.MethodBase.GetCu ...

  4. 从java代码获取类名_java代码获取当前类类名、方法名

    获取类名: 1.在类的实例中可使用this.getClass().getName();但在static method中不能使用该方法: 2.在static method中使用方法:Thread.cur ...

  5. tp框架获取控制器和方法名

    $controller = request()->controller(); $action = request()->action();

  6. ThinkPHP 3.2 中获取所有函数方法名,以及注释,完整可运行

    <?php namespace Home\Controller; use Common\Controller\BaseController; class AuthController  exte ...

  7. java 获取 正在执行的方法名

    //获取调用该方法的方法名....String method = Thread.currentThread().getStackTrace()[2].getMethodName();//获取正在执行方 ...

  8. CI框架获取控制器名和方法名

    CI获取控制器名和方法名 第一种方法: 即使有__CLASS__,__FUNCTION__魔术变量,但是在父类控制器,或者在model中,只能获取当前类的类名和方法名. 第二种方法: $this-&g ...

  9. PHP 获取当前类名、方法名、URL地址

      1.PHP获取当前类名.方法名   __CLASS__ 获取当前类名   __FUNCTION__ 当前函数名(confirm)   __METHOD__ 当前方法名 (bankcard::con ...

最新文章

  1. 【Qt】Qt程序编译成功,执行时报错:程序异常结束,crashed
  2. 从Java程序员的角度理解加密的那些事
  3. 3t studio 导出数据_Studio 3T 2019 强大的MongoDB数据库连接工具
  4. elasticSearch入门到java操作api一套搞定
  5. ASP.NET3.5 企业级项目开发 -- 第二章(续) 数据访问层(DAL)的开发解决方案提出...
  6. 源码解读腾讯 GT 的性能测试方案
  7. 利用事件冒泡实现简单的网页计算器
  8. baidumap vue 判断范围_百度地图 vue-baidu-map
  9. python---线程与进程
  10. (转)微信公众平台关于fakeid和openid的解析
  11. magento产品批量导出导入
  12. [模板] tarjan/联通分量/dfs树
  13. 数据结构-查找-折半查找-二叉排序树查找
  14. mysql vc调用时内存错误
  15. python session过期_session的工作原理、django的超时时间设置及session过期判断
  16. Java调用ffmepg+mencoder视频格式转换(*)
  17. 学校校园监控安装安全系统方案
  18. m序列产生原理及其性质
  19. RGB图片和mask合在一起
  20. mac 截图工具| Snipaste

热门文章

  1. 利用poi生成excel考勤表
  2. 知识表示(KRL)与知识嵌入(KE)
  3. 多点开花的海康威视,凭何实现“智能跃级”?
  4. YDOOK: Python3 IPC 进程间通信方法分类总结
  5. 百度统计---事件跟踪设置
  6. Bit-Z永续合约模拟邀请赛榜单公布
  7. 单招计算机专业的自我介绍,软件技术单招面试自我介绍
  8. JavaScript 基本运算符
  9. 计算机耦合分类,耦合性 (计算机科学)
  10. 关于sklearn因子分析(factor analysis)中因子旋转的问题