Common.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Controller;
  4. use think\Exception;
  5. use think\Request;
  6. use think\Session;
  7. use think\Log;
  8. use think\cache\driver\Redis;
  9. class Common extends Controller
  10. {
  11. /**
  12. * 构造函数.
  13. *
  14. * @access public
  15. * @return string
  16. */
  17. public function _initialize()
  18. {
  19. // 验证是否登陆.
  20. if (!Session::has('admin')) {
  21. return $this->redirect('Admin/Login/login');
  22. }
  23. }//end _initialize()
  24. /**
  25. * 获取当前模块.
  26. */
  27. protected function getModular()
  28. {
  29. $request = Request::instance();
  30. $controller = $request->controller();
  31. $module = $request->module();
  32. $action = $request->action();
  33. $path = $request->path();
  34. $data = [
  35. 'controller' => $controller,
  36. 'module' => $module,
  37. 'action' => $action,
  38. 'path' => $path,
  39. ];
  40. return $data;
  41. }//end getModular()
  42. }