From bfc32c483cce9cdd344118d5b14be81e9f5b4e73 Mon Sep 17 00:00:00 2001 From: Andrey Helldar Date: Thu, 20 Jun 2024 15:07:51 +0300 Subject: [PATCH 1/2] Added a new parameter to route names (`column`) --- config/public.php | 1 + src/Constants/RouteName.php | 1 + src/Data/Shared/RouteNameData.php | 1 + src/Services/Config.php | 1 + tests/Unit/SharedWithEnvTest.php | 4 ++++ tests/Unit/SharedWithoutEnvTest.php | 4 ++++ 6 files changed, 12 insertions(+) diff --git a/config/public.php b/config/public.php index 5d1f45e..d44dd2c 100644 --- a/config/public.php +++ b/config/public.php @@ -113,6 +113,7 @@ 'header' => RouteName::Header, 'cookie' => RouteName::Cookie, 'session' => RouteName::Session, + 'column' => RouteName::Column, ], /* diff --git a/src/Constants/RouteName.php b/src/Constants/RouteName.php index a0354f7..b22adfa 100644 --- a/src/Constants/RouteName.php +++ b/src/Constants/RouteName.php @@ -6,6 +6,7 @@ class RouteName { + public const Column = 'locale'; public const Cookie = 'X-Localization'; public const Header = 'X-Localization'; public const Parameter = 'locale'; diff --git a/src/Data/Shared/RouteNameData.php b/src/Data/Shared/RouteNameData.php index f172ecb..7f3cf79 100644 --- a/src/Data/Shared/RouteNameData.php +++ b/src/Data/Shared/RouteNameData.php @@ -11,5 +11,6 @@ public function __construct( public string $header, public string $cookie, public string $session, + public string $column, ) {} } diff --git a/src/Services/Config.php b/src/Services/Config.php index aecc9b3..df809a4 100644 --- a/src/Services/Config.php +++ b/src/Services/Config.php @@ -78,6 +78,7 @@ protected function routes(): RoutesData header : $this->value(Name::Shared, 'routes.names.header', fallback: RouteName::Header), cookie : $this->value(Name::Shared, 'routes.names.cookie', fallback: RouteName::Cookie), session : $this->value(Name::Shared, 'routes.names.session', fallback: RouteName::Session), + column : $this->value(Name::Shared, 'routes.names.column', fallback: RouteName::Column), ), namePrefix: $this->value(Name::Shared, 'routes.name_prefix', fallback: 'localized.'), redirect : $this->value(Name::Shared, 'routes.redirect_default', fallback: false), diff --git a/tests/Unit/SharedWithEnvTest.php b/tests/Unit/SharedWithEnvTest.php index 41babb4..ad14644 100644 --- a/tests/Unit/SharedWithEnvTest.php +++ b/tests/Unit/SharedWithEnvTest.php @@ -79,6 +79,10 @@ expect(Config::shared()->routes->names->session) ->toBeString() ->toBe(config('localization.routes.names.session')); + + expect(Config::shared()->routes->names->column) + ->toBeString() + ->toBe(config('localization.routes.names.column')); }); test('routes: name prefix', function () { diff --git a/tests/Unit/SharedWithoutEnvTest.php b/tests/Unit/SharedWithoutEnvTest.php index 41babb4..ad14644 100644 --- a/tests/Unit/SharedWithoutEnvTest.php +++ b/tests/Unit/SharedWithoutEnvTest.php @@ -79,6 +79,10 @@ expect(Config::shared()->routes->names->session) ->toBeString() ->toBe(config('localization.routes.names.session')); + + expect(Config::shared()->routes->names->column) + ->toBeString() + ->toBe(config('localization.routes.names.column')); }); test('routes: name prefix', function () { From 5807040aa4d6b92407c6b6fc8e3c11aa84a0342b Mon Sep 17 00:00:00 2001 From: Andrey Helldar Date: Thu, 20 Jun 2024 15:08:46 +0300 Subject: [PATCH 2/2] Updated doc-block --- config/public.php | 1 + 1 file changed, 1 insertion(+) diff --git a/config/public.php b/config/public.php index d44dd2c..ea391b4 100644 --- a/config/public.php +++ b/config/public.php @@ -106,6 +106,7 @@ * header - X-Localization * cookie - X-Localization * session - X-Localization + * column - column */ 'names' => [