]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Controller/ConfigController.php
Merge pull request #2677 from wallabag/add-wallabag_user.de.yml
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Controller / ConfigController.php
index d40efcd73cfe5bf88845af30e29072d915677b79..68f30f6e65e07dd6cc040136b72e0bb32a303e9a 100644 (file)
@@ -39,6 +39,8 @@ class ConfigController extends Controller
             $em->persist($config);
             $em->flush();
 
+            $request->getSession()->set('_locale', $config->getLanguage());
+
             // switch active theme
             $activeTheme = $this->get('liip_theme.active_theme');
             $activeTheme->setName($config->getTheme());
@@ -234,8 +236,6 @@ class ConfigController extends Controller
      */
     public function resetAction($type)
     {
-        $em = $this->getDoctrine()->getManager();
-
         switch ($type) {
             case 'annotations':
                 $this->getDoctrine()
@@ -363,4 +363,25 @@ class ConfigController extends Controller
 
         return $this->redirect($this->generateUrl('fos_user_security_login'));
     }
+
+    /**
+     * Switch view mode for current user.
+     *
+     * @Route("/config/view-mode", name="switch_view_mode")
+     *
+     * @param Request $request
+     *
+     * @return \Symfony\Component\HttpFoundation\RedirectResponse
+     */
+    public function changeViewModeAction(Request $request)
+    {
+        $user = $this->getUser();
+        $user->getConfig()->setListMode(!$user->getConfig()->getListMode());
+
+        $em = $this->getDoctrine()->getManager();
+        $em->persist($user);
+        $em->flush();
+
+        return $this->redirect($request->headers->get('referer'));
+    }
 }