12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace App\Utils\Control;
- class ActionUtil{
- protected array $actions = [];// 控制器信息
- protected static $instance;
- public static function getInstance(): ActionUtil
- {
- if (empty(self::$instance)) {
- self::$instance = new self();
- }
- return self::$instance;
- }
- /**
- * 获取当前路由地址
- * @return array
- */
- public function actions(){
- $action = request()->route()->getAction();
- $actions = str_replace($action['namespace'].'\\','',!empty($action['controller'])?$action['controller']:'');
- $actions = str_replace('\\','/',$actions);
- if (!empty($actions)){
- $action = explode('@',$actions);
- $this->actions['controller'] = !empty($action[0])?$action[0]:'CommonController.php';
- $this->actions['action'] = !empty($action[1])?$action[1]:'common';
- }else{
- $this->actions['controller'] = 'CommonController.php';
- $this->actions['action'] = 'common';
- }
- return $this->actions;
- }
- public function get()
- {
- return $this->actions;
- }
- }
|