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.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 7540f756..b3236e3c 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -8,6 +8,7 @@ use Symfony\Component\HttpFoundation\Request;
8use Wallabag\CoreBundle\Entity\Config; 8use Wallabag\CoreBundle\Entity\Config;
9use Wallabag\CoreBundle\Form\Type\ConfigType; 9use Wallabag\CoreBundle\Form\Type\ConfigType;
10use Wallabag\CoreBundle\Form\Type\ChangePasswordType; 10use Wallabag\CoreBundle\Form\Type\ChangePasswordType;
11use Wallabag\CoreBundle\Form\Type\UserType;
11 12
12class ConfigController extends Controller 13class ConfigController extends Controller
13{ 14{
@@ -20,13 +21,13 @@ class ConfigController extends Controller
20 { 21 {
21 $em = $this->getDoctrine()->getManager(); 22 $em = $this->getDoctrine()->getManager();
22 $config = $this->getConfig(); 23 $config = $this->getConfig();
24 $user = $this->getUser();
23 25
24 // handle basic config detail 26 // handle basic config detail
25 $configForm = $this->createForm(new ConfigType(), $config); 27 $configForm = $this->createForm(new ConfigType(), $config);
26 $configForm->handleRequest($request); 28 $configForm->handleRequest($request);
27 29
28 if ($configForm->isValid()) { 30 if ($configForm->isValid()) {
29
30 $em->persist($config); 31 $em->persist($config);
31 $em->flush(); 32 $em->flush();
32 33
@@ -43,7 +44,6 @@ class ConfigController extends Controller
43 $pwdForm->handleRequest($request); 44 $pwdForm->handleRequest($request);
44 45
45 if ($pwdForm->isValid()) { 46 if ($pwdForm->isValid()) {
46 $user = $this->getUser();
47 $user->setPassword($pwdForm->get('new_password')->getData()); 47 $user->setPassword($pwdForm->get('new_password')->getData());
48 $em->persist($user); 48 $em->persist($user);
49 $em->flush(); 49 $em->flush();
@@ -56,9 +56,26 @@ class ConfigController extends Controller
56 return $this->redirect($this->generateUrl('config')); 56 return $this->redirect($this->generateUrl('config'));
57 } 57 }
58 58
59 // handle changing user information
60 $userForm = $this->createForm(new UserType(), $user);
61 $userForm->handleRequest($request);
62
63 if ($userForm->isValid()) {
64 $em->persist($user);
65 $em->flush();
66
67 $this->get('session')->getFlashBag()->add(
68 'notice',
69 'Information updated'
70 );
71
72 return $this->redirect($this->generateUrl('config'));
73 }
74
59 return $this->render('WallabagCoreBundle:Config:index.html.twig', array( 75 return $this->render('WallabagCoreBundle:Config:index.html.twig', array(
60 'configForm' => $configForm->createView(), 76 'configForm' => $configForm->createView(),
61 'pwdForm' => $pwdForm->createView(), 77 'pwdForm' => $pwdForm->createView(),
78 'userForm' => $userForm->createView(),
62 )); 79 ));
63 } 80 }
64 81