From 0ba0fe689cd68435dd453f06af73e55b9e60247c Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Wed, 22 Mar 2017 19:14:14 +0000 Subject: [PATCH 1/2] Revert the Kernel's Trait --- _docs/1-Installation-and-Setup.md | 17 +++++++++++++ src/Traits/LocalizationKernelTrait.php | 33 ++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/_docs/1-Installation-and-Setup.md b/_docs/1-Installation-and-Setup.md index aba8349..a86f0bd 100644 --- a/_docs/1-Installation-and-Setup.md +++ b/_docs/1-Installation-and-Setup.md @@ -56,6 +56,23 @@ Once the package is installed, you can register the service provider in `config/ > No need to register the Localization facade, it's done automagically. +##### Now you need to update your Http Kernel to use the Localization Router. + +```php +// app/Http/Kernel.php + * - * @deprecated since v1.0.3 + * @property \Illuminate\Foundation\Application app + * @property \Arcanedev\Localization\Routing\Router router + * @property array middlewareGroups + * @property array routeMiddleware */ trait LocalizationKernelTrait { - // + /** + * Get the route dispatcher callback. + * + * @return \Closure + */ + protected function dispatchToRouter() + { + $this->replaceRouter(); + + return parent::dispatchToRouter(); + } + + /** + * Replace the illuminate router with the localization router. + */ + protected function replaceRouter() + { + $this->router = $this->app->make('router'); + + foreach ($this->middlewareGroups as $key => $middleware) { + $this->router->middlewareGroup($key, $middleware); + } + + foreach ($this->routeMiddleware as $key => $middleware) { + $this->router->aliasMiddleware($key, $middleware); + } + } } From 7ab30f6341d034557d86af4a571993e3e191be4f Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Wed, 22 Mar 2017 19:30:23 +0000 Subject: [PATCH 2/2] Updating config file with a new feature: ignored-uri --- _docs/2-Configuration.md | 10 ++++++++++ config/localization.php | 9 +++++++++ src/Middleware/Middleware.php | 1 + 3 files changed, 20 insertions(+) diff --git a/_docs/2-Configuration.md b/_docs/2-Configuration.md index 3f1d324..36bab28 100644 --- a/_docs/2-Configuration.md +++ b/_docs/2-Configuration.md @@ -63,6 +63,16 @@ return [ | localized-routes | Allows to register all translatable routes. | | translation-redirect | Allows to translate the route attributes by using the translation event. | +## Ignored URI + +```php + 'ignored-uri' => [ + // + ], +``` + +You can set a list of uris to ignore from localization checks. + ## Locales ```php diff --git a/config/localization.php b/config/localization.php index d11fea3..428f613 100644 --- a/config/localization.php +++ b/config/localization.php @@ -30,6 +30,15 @@ ], ], + /* ----------------------------------------------------------------- + | Ignored URI from localization + | ----------------------------------------------------------------- + */ + + 'ignored-uri' => [ + // + ], + /* ----------------------------------------------------------------- | Locales | ----------------------------------------------------------------- diff --git a/src/Middleware/Middleware.php b/src/Middleware/Middleware.php index d535317..370725b 100644 --- a/src/Middleware/Middleware.php +++ b/src/Middleware/Middleware.php @@ -44,6 +44,7 @@ abstract class Middleware extends BaseMiddleware public function __construct(Localization $localization) { $this->localization = $localization; + $this->except = config('localization.ignored-uri', []); } /* -----------------------------------------------------------------