From 4d85d7e9ba676bd5ac3428976ce9227f460eb542 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 16 Feb 2015 21:28:49 +0100 Subject: Implement simple config --- .../CoreBundle/Controller/ConfigController.php | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/Wallabag/CoreBundle/Controller/ConfigController.php (limited to 'src/Wallabag/CoreBundle/Controller/ConfigController.php') diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php new file mode 100644 index 00000000..f48a9cb1 --- /dev/null +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -0,0 +1,58 @@ +getConfig(); + + $form = $this->createForm(new ConfigType(), $config); + + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($config); + $em->flush(); + + $this->get('session')->getFlashBag()->add( + 'notice', + 'Config saved' + ); + + return $this->redirect($this->generateUrl('config')); + } + + return $this->render('WallabagCoreBundle:Config:index.html.twig', array( + 'form' => $form->createView(), + )); + } + + private function getConfig() + { + $config = $this->getDoctrine() + ->getRepository('WallabagCoreBundle:Config') + ->findOneByUser($this->getUser()); + + if (!$config) { + $config = new Config($this->getUser()); + } + + return $config; + } +} -- cgit v1.2.3