Skip to content

Commit

Permalink
Merge pull request #6 from Laravel-Lang/1.x
Browse files Browse the repository at this point in the history
Middleware renamed to more appropriate names
  • Loading branch information
andrey-helldar authored Jun 9, 2024
2 parents c041415 + 0fe4b63 commit 82f77b4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Illuminate\Http\Request;

class CookiesLocale extends Middleware
class LocalizationByCookie extends Middleware
{
protected function detect(Request $request): bool|float|int|string|null
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Illuminate\Http\Request;

class HeaderLocale extends Middleware
class LocalizationByHeader extends Middleware
{
protected function detect(Request $request): bool|float|int|string|null
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Illuminate\Http\Request;

class ParameterLocale extends Middleware
class LocalizationByParameter extends Middleware
{
protected function detect(Request $request): bool|float|int|string|null
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use function array_merge;
use function response;

class ParameterRedirectLocale extends Middleware
class LocalizationByParameterWithRedirect extends Middleware
{
use KeyNames;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Illuminate\Http\Request;

class SessionLocale extends Middleware
class LocalizationBySession extends Middleware
{
protected function detect(Request $request): bool|float|int|string|null
{
Expand Down
22 changes: 11 additions & 11 deletions tests/Concerns/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
namespace Tests\Concerns;

use Closure;
use LaravelLang\Routes\Middlewares\CookiesLocale;
use LaravelLang\Routes\Middlewares\HeaderLocale;
use LaravelLang\Routes\Middlewares\ParameterLocale;
use LaravelLang\Routes\Middlewares\ParameterRedirectLocale;
use LaravelLang\Routes\Middlewares\SessionLocale;
use LaravelLang\Routes\Middlewares\LocalizationByCookie;
use LaravelLang\Routes\Middlewares\LocalizationByHeader;
use LaravelLang\Routes\Middlewares\LocalizationByParameter;
use LaravelLang\Routes\Middlewares\LocalizationByParameterWithRedirect;
use LaravelLang\Routes\Middlewares\LocalizationBySession;
use Tests\Constants\LocaleValue;

use function app;
Expand All @@ -24,31 +24,31 @@ public function setUpRoutes(): void
->middleware('web')
->group(function () {
app('router')
->middleware(ParameterLocale::class)
->middleware(LocalizationByParameter::class)
->get('path/{foo}/{locale?}', $this->jsonResponse())
->name('via.parameter');

app('router')
->middleware(ParameterRedirectLocale::class)
->middleware(LocalizationByParameterWithRedirect::class)
->get('redirect/{foo}/{locale?}', $this->jsonResponse())
->name('via.parameter.redirect');

app('router')
->middleware(ParameterRedirectLocale::class)
->middleware(LocalizationByParameterWithRedirect::class)
->get('not-named/redirect/{foo}/{locale?}', $this->jsonResponse());

app('router')
->middleware(HeaderLocale::class)
->middleware(LocalizationByHeader::class)
->get('header/{foo}', $this->jsonResponse())
->name('via.header');

app('router')
->middleware(CookiesLocale::class)
->middleware(LocalizationByCookie::class)
->get('cookie/{foo}', $this->jsonResponse())
->name('via.cookie');

app('router')
->middleware(SessionLocale::class)
->middleware(LocalizationBySession::class)
->get('session/{foo}', $this->jsonResponse())
->name('via.session');
});
Expand Down

0 comments on commit 82f77b4

Please # to comment.