AlertController.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\controllers;
  3. use Yii;
  4. use \app\common\controllers\CController;
  5. class AlertController extends CController
  6. {
  7. public function actionError()
  8. {
  9. $exception = Yii::$app->errorHandler->exception;
  10. if ($exception !== null) {
  11. if($exception->getCode()==404)
  12. {
  13. return $this->renderPartial('lost');
  14. }
  15. else
  16. {
  17. $code = $exception->getCode()?$exception->getCode():'500';
  18. $data = [
  19. 'code' => $code,
  20. 'message' => $exception->getMessage(),
  21. 'file' => $exception->getFile(),
  22. 'line' => $exception->getLine(),
  23. 'lastnum'=>substr($code,2,1),
  24. 'homeurl'=>APP_URL
  25. ];
  26. if(defined('IN_ADMIN')&&IN_ADMIN==true)
  27. {
  28. $data['homeurl'] = $this->adminHomeUrl;
  29. }
  30. return $this->renderPartial('error', $data);
  31. }
  32. }
  33. }
  34. }