SiteController.php 717 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace frontend\controllers;
  3. use Yii;
  4. use yii\web\Controller;
  5. class SiteController extends BaseController
  6. {
  7. public function actionIndex()
  8. {
  9. return $this->render('index');
  10. }
  11. /**
  12. * 错误处理器
  13. * @return string|\yii\web\Response
  14. */
  15. public function actionError()
  16. {
  17. $handler = Yii::$app->getErrorHandler();
  18. $exception = $handler->exception;
  19. if ($exception == null) {
  20. // 没有异常
  21. $exception = new NotFoundHttpException();
  22. }
  23. $response = Yii::$app->getResponse();
  24. $response->setStatusCodeByException($exception);
  25. return $this->renderPartial('/site/error404.php');
  26. }
  27. }