diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 13d3e65f..7653c410 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -3,6 +3,7 @@ namespace App\Exceptions; use Exception; +use App\Exceptions\PrettyPageException; use App\Http\Middleware\Internationalization; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Foundation\Validation\ValidationException; @@ -20,7 +21,8 @@ class Handler extends ExceptionHandler protected $dontReport = [ HttpException::class, ModelNotFoundException::class, - ValidationException::class + ValidationException::class, + PrettyPageException::class ]; /** @@ -50,10 +52,7 @@ class Handler extends ExceptionHandler } if ($e instanceof PrettyPageException && PHP_SAPI != "cli") { - echo \View::make('errors.e')->with('code', $e->getCode()) - ->with('message', $e->getMessage()) - ->render(); - exit; + return $e->showErrorPage(); } if ($e instanceof HttpException) { diff --git a/app/Exceptions/PrettyPageException.php b/app/Exceptions/PrettyPageException.php index 739f748e..e3934998 100644 --- a/app/Exceptions/PrettyPageException.php +++ b/app/Exceptions/PrettyPageException.php @@ -11,19 +11,18 @@ class PrettyPageException extends \Exception * @param integer $code * @param boolean $render, to show a error page */ - function __construct($message = "Error occured.", $code = -1, $render = false) + public function __construct($message = "Error occured.", $code = -1, $render = false) { parent::__construct($message, $code); - if ($render) - $this->showErrorPage(); + if ($render) { + $this->showErrorPage()->send(); + exit; + } } - private function showErrorPage() + public function showErrorPage() { - echo \View::make('errors.e')->with('code', $this->code) - ->with('message', $this->message) - ->render(); - exit; + return response()->view('errors.pretty', ['code' => $this->code, 'message' => $this->message]); } } diff --git a/resources/views/errors/e.tpl b/resources/views/errors/e.tpl deleted file mode 100644 index dc834a1e..00000000 --- a/resources/views/errors/e.tpl +++ /dev/null @@ -1,10 +0,0 @@ -@extends('errors.general') - -@section('title', trans('errors.general.title')) - -@section('content') -
{{ trans('error.exception.code', ['code' => $code]) }}
-{!! trans('error.exception.message', ['message' => $message]) !!}
-@endsection diff --git a/resources/views/errors/pretty.tpl b/resources/views/errors/pretty.tpl new file mode 100644 index 00000000..0d4ea8a2 --- /dev/null +++ b/resources/views/errors/pretty.tpl @@ -0,0 +1,10 @@ +@extends('errors.general') + +@section('title', trans('errors.general.title')) + +@section('content') +{{ trans('errors.exception.code', ['code' => $code]) }}
+{!! trans('errors.exception.message', ['msg' => $message]) !!}
+@endsection diff --git a/setup/includes/bootstrap.php b/setup/includes/bootstrap.php index 15149cc8..9aaedaaf 100644 --- a/setup/includes/bootstrap.php +++ b/setup/includes/bootstrap.php @@ -58,6 +58,7 @@ foreach ($config['aliases'] as $facade => $class) { (new Illuminate\Filesystem\FilesystemServiceProvider($app))->register(); (new Illuminate\Session\SessionServiceProvider($app))->register(); (new Illuminate\Encryption\EncryptionServiceProvider($app))->register(); +(new Devitek\Core\Translation\TranslationServiceProvider($app))->register(); $request = Symfony\Component\HttpFoundation\Request::createFromGlobals(); diff --git a/setup/includes/helpers.php b/setup/includes/helpers.php index 58cbc511..8c4173fc 100644 --- a/setup/includes/helpers.php +++ b/setup/includes/helpers.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-09-14 16:57:37 * @Last Modified by: printempw - * @Last Modified time: 2016-09-14 19:53:22 + * @Last Modified time: 2016-09-30 23:18:56 */ function check_table_exists() { @@ -20,14 +20,14 @@ function check_table_exists() { } function redirect_to($url, $msg = "") { - if ($msg !== "") { - if (app()->bound('session')) { - Session::put('msg', $msg); - Session::save(); - } else { + // if ($msg !== "") { + // if (app()->bound('session')) { + // Session::put('msg', $msg); + // Session::save(); + // } else { $_SESSION['msg'] = $msg; - } - } + // } + // } if (!headers_sent()) { header('Location: '.$url);