public function indexAction() { $exception = $this->request->getParam('exception'); if (!$exception instanceof \Exception) { return ['exception' => $exception, 'message' => static::ERROR]; } $code = $exception->getCode() ?: 404; $message = env('development') || $code === 403 ? $exception->getMessage() : static::ERROR; if ($this->request->isAjax()) { return new JsonResponse(['error' => ['message' => $exception->getMessage(), 'code' => $exception->getCode(), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'trace' => $exception->getTrace()]], $code); } if ($exception->getCode() === 403) { if (Auth::identity() === \null) { if (is_allowed(app('router')->getRoute('admin-login')->getHandler())) { return new RedirectResponse(route('admin-login', ['backTo' => urlencode(route())])); } } } $this->response->setCode($code); return ['exception' => $exception, 'message' => $message]; }
/** * (non-PHPdoc) * @see \Micro\Database\Table\Row\RowAbstract::save() */ public function save() { if ($this->_table) { $cols = $this->_table->info(TableAbstract::COLS); } else { $cols = array(); } if (empty($this->_cleanData) && in_array('created', $cols)) { $this->created = new Expr('NOW()'); } if (in_array('edited', $cols)) { $this->edited = new Expr('NOW()'); } $identity = Auth::identity(); if ($identity instanceof Identity) { if (in_array('owner', $cols) && (empty($this->_cleanData) || !$this->owner)) { $this->owner = $identity->getId(); } if (in_array('editor', $cols)) { $this->editor = $identity->getId(); } } return parent::save(); }
/** * @param unknown $force * @return \Micro\Auth\Identity */ function identity($force = \false) { return Auth::identity($force); }