diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/ConfigController.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 242f557f..be6feb7c 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php | |||
@@ -8,6 +8,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse; | |||
8 | use Symfony\Component\HttpFoundation\Request; | 8 | use Symfony\Component\HttpFoundation\Request; |
9 | use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; | 9 | use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; |
10 | use Symfony\Component\Routing\Annotation\Route; | 10 | use Symfony\Component\Routing\Annotation\Route; |
11 | use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint; | ||
11 | use Wallabag\CoreBundle\Entity\Config; | 12 | use Wallabag\CoreBundle\Entity\Config; |
12 | use Wallabag\CoreBundle\Entity\TaggingRule; | 13 | use Wallabag\CoreBundle\Entity\TaggingRule; |
13 | use Wallabag\CoreBundle\Form\Type\ChangePasswordType; | 14 | use Wallabag\CoreBundle\Form\Type\ChangePasswordType; |
@@ -330,6 +331,27 @@ class ConfigController extends Controller | |||
330 | } | 331 | } |
331 | 332 | ||
332 | /** | 333 | /** |
334 | * Change the locale for the current user. | ||
335 | * | ||
336 | * @param Request $request | ||
337 | * @param string $language | ||
338 | * | ||
339 | * @Route("/locale/{language}", name="changeLocale") | ||
340 | * | ||
341 | * @return \Symfony\Component\HttpFoundation\RedirectResponse | ||
342 | */ | ||
343 | public function setLocaleAction(Request $request, $language = null) | ||
344 | { | ||
345 | $errors = $this->get('validator')->validate($language, (new LocaleConstraint())); | ||
346 | |||
347 | if (0 === \count($errors)) { | ||
348 | $request->getSession()->set('_locale', $language); | ||
349 | } | ||
350 | |||
351 | return $this->redirect($request->headers->get('referer', $this->generateUrl('homepage'))); | ||
352 | } | ||
353 | |||
354 | /** | ||
333 | * Remove all tags for given tags and a given user and cleanup orphan tags. | 355 | * Remove all tags for given tags and a given user and cleanup orphan tags. |
334 | * | 356 | * |
335 | * @param array $tags | 357 | * @param array $tags |