aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php39
1 files changed, 32 insertions, 7 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index f48a9cb1..7540f756 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -7,6 +7,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 7use 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;
10 11
11class ConfigController extends Controller 12class ConfigController extends Controller
12{ 13{
@@ -14,19 +15,18 @@ class ConfigController extends Controller
14 * @param Request $request 15 * @param Request $request
15 * 16 *
16 * @Route("/config", name="config") 17 * @Route("/config", name="config")
17 *
18 * @return \Symfony\Component\HttpFoundation\Response
19 */ 18 */
20 public function indexAction(Request $request) 19 public function indexAction(Request $request)
21 { 20 {
21 $em = $this->getDoctrine()->getManager();
22 $config = $this->getConfig(); 22 $config = $this->getConfig();
23 23
24 $form = $this->createForm(new ConfigType(), $config); 24 // handle basic config detail
25 $configForm = $this->createForm(new ConfigType(), $config);
26 $configForm->handleRequest($request);
25 27
26 $form->handleRequest($request); 28 if ($configForm->isValid()) {
27 29
28 if ($form->isValid()) {
29 $em = $this->getDoctrine()->getManager();
30 $em->persist($config); 30 $em->persist($config);
31 $em->flush(); 31 $em->flush();
32 32
@@ -38,11 +38,36 @@ class ConfigController extends Controller
38 return $this->redirect($this->generateUrl('config')); 38 return $this->redirect($this->generateUrl('config'));
39 } 39 }
40 40
41 // handle changing password
42 $pwdForm = $this->createForm(new ChangePasswordType());
43 $pwdForm->handleRequest($request);
44
45 if ($pwdForm->isValid()) {
46 $user = $this->getUser();
47 $user->setPassword($pwdForm->get('new_password')->getData());
48 $em->persist($user);
49 $em->flush();
50
51 $this->get('session')->getFlashBag()->add(
52 'notice',
53 'Password updated'
54 );
55
56 return $this->redirect($this->generateUrl('config'));
57 }
58
41 return $this->render('WallabagCoreBundle:Config:index.html.twig', array( 59 return $this->render('WallabagCoreBundle:Config:index.html.twig', array(
42 'form' => $form->createView(), 60 'configForm' => $configForm->createView(),
61 'pwdForm' => $pwdForm->createView(),
43 )); 62 ));
44 } 63 }
45 64
65 /**
66 * Retrieve config for the current user.
67 * If no config were found, create a new one.
68 *
69 * @return Wallabag\CoreBundle\Entity\Config
70 */
46 private function getConfig() 71 private function getConfig()
47 { 72 {
48 $config = $this->getDoctrine() 73 $config = $this->getDoctrine()