FEATURE #2503: add easier installer

This commit is contained in:
Michal Kváček
2017-08-24 14:15:08 +02:00
parent 8946ef7441
commit ce183d4805
9 changed files with 9921 additions and 6040 deletions
@@ -1,5 +1,6 @@
<?php namespace App\Providers;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
@@ -8,8 +9,19 @@ class LaravelLocalizationServiceProvider extends ServiceProvider
{
public function register()
{
$languages = DB::table('languages')
->get();
try {
$languages = DB::table('languages')
->get();
} catch (QueryException $e) {
$supportedLocales[config('app.locale')] = [
'native' => env('LOCALE_NATIVE_NAME', config('app.locale')),
'script' => env('LOCALE_SCRIPT', 'Latn'),
'name' => env('LOCALE_TRANSLATED_NAME', config('app.locale')),
'code' => config('app.locale'),
];
$this->setSupportedLocales($supportedLocales);
return;
}
$supportedLocales = [];
if (empty($languages)) {
@@ -32,15 +44,20 @@ class LaravelLocalizationServiceProvider extends ServiceProvider
];
}
config([
'laravellocalization.supportedLocales' => $supportedLocales,
'laravellocalization.useAcceptLanguageHeader' => true,
'laravellocalization.hideDefaultLocaleInURL' => true
]);
$this->setSupportedLocales($supportedLocales);
}
public function boot()
{
\App::setLocale(LaravelLocalization::getCurrentLocale());
}
private function setSupportedLocales($supportedLocales)
{
config([
'laravellocalization.supportedLocales' => $supportedLocales,
'laravellocalization.useAcceptLanguageHeader' => true,
'laravellocalization.hideDefaultLocaleInURL' => true
]);
}
}
+6 -1
View File
@@ -6,6 +6,7 @@ use App\CMS\Contracts\Repositories\Template as TemplateContract;
use App\CMS\Handlers\Registrators\TemplateRegistrator;
use App\CMS\Helpers\CurrentTemplate;
use App\CMS\Repositories\Module;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\App;
use Illuminate\Support\ServiceProvider;
@@ -13,7 +14,11 @@ class TemplateServiceProvider extends ServiceProvider
{
public function boot()
{
$template = CurrentTemplate::get();
try {
$template = CurrentTemplate::get();
} catch (QueryException $e) {
return;
}
// ignore running from artisan
if (App::runningInConsole() || App::environment('testing') || !$template) {