aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/ConfigController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/ConfigController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index b999c539..be6feb7c 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -2,12 +2,13 @@
2 2
3namespace Wallabag\CoreBundle\Controller; 3namespace Wallabag\CoreBundle\Controller;
4 4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller; 5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\JsonResponse; 6use Symfony\Component\HttpFoundation\JsonResponse;
8use Symfony\Component\HttpFoundation\RedirectResponse; 7use Symfony\Component\HttpFoundation\RedirectResponse;
9use Symfony\Component\HttpFoundation\Request; 8use Symfony\Component\HttpFoundation\Request;
10use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; 9use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
10use Symfony\Component\Routing\Annotation\Route;
11use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint;
11use Wallabag\CoreBundle\Entity\Config; 12use Wallabag\CoreBundle\Entity\Config;
12use Wallabag\CoreBundle\Entity\TaggingRule; 13use Wallabag\CoreBundle\Entity\TaggingRule;
13use Wallabag\CoreBundle\Form\Type\ChangePasswordType; 14use 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