-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tec: Extract a LocaleSorter from OrganizationSorter
- Loading branch information
1 parent
a84479c
commit 8ad6c22
Showing
2 changed files
with
31 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
// This file is part of Bileto. | ||
// Copyright 2022-2023 Probesys | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
namespace App\Service; | ||
|
||
use App\Utils\Locales; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
|
||
class LocaleSorter | ||
{ | ||
private RequestStack $requestStack; | ||
|
||
public function __construct(RequestStack $requestStack) | ||
{ | ||
$this->requestStack = $requestStack; | ||
} | ||
|
||
protected function getLocale(): string | ||
{ | ||
$currentRequest = $this->requestStack->getCurrentRequest(); | ||
if ($currentRequest) { | ||
return $currentRequest->getLocale(); | ||
} else { | ||
return Locales::DEFAULT_LOCALE; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters