/** * Auth constructor. */ public function __construct() { $controller = Controller::current(); $this->action = $controller->getAction(); $this->ruler = $controller->getRuler(); $this->param = $controller->getParam(); }
/** * 业务层有抛出错误 */ public function _fail() { $code = $this->getFromHead('code'); if ($code) { $this->out('code', $code); } $msg = $this->getFromHead('msg'); if ($msg) { $this->out('code', $msg); } $this->out('title', '操作失败'); Controller::current()->setTemplate('error/fail'); }
/** * 寻找当前的ACTION * * @param string $method * * @return \jt\Controller|\jt\ErrorHandler */ private static final function getAction(&$method) { $controller = Controller::current(); $action = $controller->getAction(); if ($action && method_exists($action, $method)) { return $action; } if (!$controller->loadAction('\\app\\' . MODULE . '\\action\\ErrorHandler', $method)) { if (!$controller->loadAction('\\jt\\ErrorHandler', $method) && $method !== 'unkown_error') { $method = 'unkown_error'; return self::getAction($method); } } return $controller->getAction(); }