Skip to content

Commit

Permalink
Merge pull request #28 from Laravel-Lang/1.x
Browse files Browse the repository at this point in the history
Added a new parameter to route names (`column`)
  • Loading branch information
andrey-helldar authored Jun 20, 2024
2 parents 1115cd3 + 5807040 commit ecec07c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/public.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@
* header - X-Localization
* cookie - X-Localization
* session - X-Localization
* column - column
*/

'names' => [
'parameter' => RouteName::Parameter,
'header' => RouteName::Header,
'cookie' => RouteName::Cookie,
'session' => RouteName::Session,
'column' => RouteName::Column,
],

/*
Expand Down
1 change: 1 addition & 0 deletions src/Constants/RouteName.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class RouteName
{
public const Column = 'locale';
public const Cookie = 'X-Localization';
public const Header = 'X-Localization';
public const Parameter = 'locale';
Expand Down
1 change: 1 addition & 0 deletions src/Data/Shared/RouteNameData.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public function __construct(
public string $header,
public string $cookie,
public string $session,
public string $column,
) {}
}
1 change: 1 addition & 0 deletions src/Services/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 4 additions & 0 deletions tests/Unit/SharedWithEnvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
4 changes: 4 additions & 0 deletions tests/Unit/SharedWithoutEnvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit ecec07c

Please sign in to comment.