mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-22 20:54:52 +00:00
make redirect to user locale selected #19
This commit is contained in:
parent
f85414fd2b
commit
9fcc5a451b
@ -7,15 +7,25 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
use App\Service\UserService;
|
||||||
|
|
||||||
class DashboardController extends AbstractController
|
class DashboardController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/')]
|
#[Route('/')]
|
||||||
public function root(): Response
|
public function root(
|
||||||
|
Request $request,
|
||||||
|
UserService $userService
|
||||||
|
): Response
|
||||||
{
|
{
|
||||||
|
// Init user
|
||||||
|
$user = $userService->init(
|
||||||
|
$request->getClientIp()
|
||||||
|
);
|
||||||
|
|
||||||
return $this->redirectToRoute(
|
return $this->redirectToRoute(
|
||||||
'dashboard_index',
|
'dashboard_index',
|
||||||
[
|
[
|
||||||
'_locale' => $this->getParameter('app.locale')
|
'_locale' => $user->getLocale()
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,8 @@ class UserController extends AbstractController
|
|||||||
public function profile(
|
public function profile(
|
||||||
Request $request,
|
Request $request,
|
||||||
UserService $userService,
|
UserService $userService,
|
||||||
TimeService $timeService): Response
|
TimeService $timeService
|
||||||
|
): Response
|
||||||
{
|
{
|
||||||
// Init user
|
// Init user
|
||||||
$user = $userService->init(
|
$user = $userService->init(
|
||||||
@ -53,6 +54,14 @@ class UserController extends AbstractController
|
|||||||
|
|
||||||
// Save changes to DB
|
// Save changes to DB
|
||||||
$userService->save($user);
|
$userService->save($user);
|
||||||
|
|
||||||
|
// Redirect user to new locale
|
||||||
|
return $this->redirectToRoute(
|
||||||
|
'user_profile',
|
||||||
|
[
|
||||||
|
'_locale' => $user->getLocale()
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate identicon
|
// Generate identicon
|
||||||
|
@ -14,7 +14,10 @@ class UserService
|
|||||||
private UserRepository $userRepository;
|
private UserRepository $userRepository;
|
||||||
private ParameterBagInterface $parameterBagInterface;
|
private ParameterBagInterface $parameterBagInterface;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $entityManager, ParameterBagInterface $parameterBagInterface)
|
public function __construct(
|
||||||
|
EntityManagerInterface $entityManager,
|
||||||
|
ParameterBagInterface $parameterBagInterface
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$this->entityManager = $entityManager;
|
$this->entityManager = $entityManager;
|
||||||
$this->userRepository = $entityManager->getRepository(User::class);
|
$this->userRepository = $entityManager->getRepository(User::class);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user