Skip to content

Commit

Permalink
Merge pull request #17 from Laravel-Lang/1.x
Browse files Browse the repository at this point in the history
Route header values moved to constants
  • Loading branch information
andrey-helldar authored Jun 12, 2024
2 parents a0c039c + 421119c commit 55d3f48
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
9 changes: 5 additions & 4 deletions config/public.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use LaravelLang\Config\Constants\RouteName;
use LaravelLang\LocaleList\Locale;

return [
Expand Down Expand Up @@ -108,10 +109,10 @@
*/

'names' => [
'parameter' => 'locale',
'header' => 'X-Localization',
'cookie' => 'X-Localization',
'session' => 'X-Localization',
'parameter' => RouteName::Parameter,
'header' => RouteName::Header,
'cookie' => RouteName::Cookie,
'session' => RouteName::Session,
],
],

Expand Down
13 changes: 13 additions & 0 deletions src/Constants/RouteName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace LaravelLang\Config\Constants;

class RouteName
{
public const Cookie = 'X-Localization';
public const Header = 'X-Localization';
public const Parameter = 'locale';
public const Session = 'X-Localization';
}
7 changes: 4 additions & 3 deletions src/Services/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace LaravelLang\Config\Services;

use Illuminate\Config\Repository;
use LaravelLang\Config\Constants\RouteName;
use LaravelLang\Config\Data\Common\NonPushableData;
use LaravelLang\Config\Data\Common\PushableData;
use LaravelLang\Config\Data\Hidden\ModelsData as HiddenModelsData;
Expand Down Expand Up @@ -74,9 +75,9 @@ protected function routes(): RoutesData
return new RoutesData(
names: new RouteNameData(
parameter: $this->value(Name::Shared, 'routes.names.parameter', fallback: 'locale'),
header : $this->value(Name::Shared, 'routes.names.header', fallback: 'X-Localization'),
cookie : $this->value(Name::Shared, 'routes.names.cookie', fallback: 'X-Localization'),
session : $this->value(Name::Shared, 'routes.names.session', fallback: 'X-Localization'),
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),
)
);
}
Expand Down

0 comments on commit 55d3f48

Please sign in to comment.