diff --git a/composer.json b/composer.json index c2f5891..c76ad74 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "license": "MIT", "require": { "php": ">=7.0", - "arcanedev/support": "~4.1" + "arcanedev/support": "~4.2.0" }, "require-dev": { "phpunit/phpcov": "~4.0", @@ -39,10 +39,7 @@ "laravel": { "providers": [ "Arcanedev\\Localization\\LocalizationServiceProvider" - ], - "aliases": { - "Localization": "Arcanedev\\Localization\\Facades\\Localization" - } + ] } }, "suggest": { diff --git a/config/localization.php b/config/localization.php index 428f613..1c6885e 100644 --- a/config/localization.php +++ b/config/localization.php @@ -13,6 +13,8 @@ 'hide-default-in-url' => false, + 'redirection-code' => 302, + 'facade' => 'Localization', /* ----------------------------------------------------------------- diff --git a/src/LocalizationServiceProvider.php b/src/LocalizationServiceProvider.php index ce8f097..0e52c03 100644 --- a/src/LocalizationServiceProvider.php +++ b/src/LocalizationServiceProvider.php @@ -40,7 +40,6 @@ public function register() Providers\UtilitiesServiceProvider::class, ]); $this->registerLocalization(); - $this->registerAliases(); } /** @@ -78,9 +77,10 @@ private function registerLocalization() { $this->singleton(Contracts\Localization::class, Localization::class); - $this->alias( - $this->config()->get('localization.facade', 'Localization'), - Facades\Localization::class - ); + if ($alias = $this->config()->get('localization.facade')) { + $this->alias($alias, Facades\Localization::class); + + $this->registerAliases(); + } } } diff --git a/src/Middleware/Middleware.php b/src/Middleware/Middleware.php index 2ce9b69..e95899f 100644 --- a/src/Middleware/Middleware.php +++ b/src/Middleware/Middleware.php @@ -154,13 +154,13 @@ protected function getLocalizedRedirect($locale) /** * Make a redirect response. * - * @param string $url - * @param int $code + * @param string $url + * @param int|null $code * * @return \Illuminate\Http\RedirectResponse */ - protected function makeRedirectResponse($url, $code = 302) + protected function makeRedirectResponse($url, $code = null) { - return new RedirectResponse($url, $code, ['Vary' => 'Accept-Language']); + return new RedirectResponse($url, $code ?? config('localization.redirection-code', 302), ['Vary' => 'Accept-Language']); } }