aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/ConfigController.php
diff options
context:
space:
mode:
authorJeremy <jeremy.benoist@gmail.com>2015-02-16 21:28:49 +0100
committerJeremy <jeremy.benoist@gmail.com>2015-02-16 21:31:58 +0100
commit4d85d7e9ba676bd5ac3428976ce9227f460eb542 (patch)
treeacf77c5baced69e689fcfc2d9463a9b75b9b3657 /src/Wallabag/CoreBundle/Controller/ConfigController.php
parent7a577c519ffc254b6ddecd75c9ee84f656d759e1 (diff)
downloadwallabag-4d85d7e9ba676bd5ac3428976ce9227f460eb542.tar.gz
wallabag-4d85d7e9ba676bd5ac3428976ce9227f460eb542.tar.zst
wallabag-4d85d7e9ba676bd5ac3428976ce9227f460eb542.zip
Implement simple config
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/ConfigController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php58
1 files changed, 58 insertions, 0 deletions
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 @@
1<?php
2
3namespace Wallabag\CoreBundle\Controller;
4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request;
8use Wallabag\CoreBundle\Entity\Config;
9use Wallabag\CoreBundle\Form\Type\ConfigType;
10
11class ConfigController extends Controller
12{
13 /**
14 * @param Request $request
15 *
16 * @Route("/config", name="config")
17 *
18 * @return \Symfony\Component\HttpFoundation\Response
19 */
20 public function indexAction(Request $request)
21 {
22 $config = $this->getConfig();
23
24 $form = $this->createForm(new ConfigType(), $config);
25
26 $form->handleRequest($request);
27
28 if ($form->isValid()) {
29 $em = $this->getDoctrine()->getManager();
30 $em->persist($config);
31 $em->flush();
32
33 $this->get('session')->getFlashBag()->add(
34 'notice',
35 'Config saved'
36 );
37
38 return $this->redirect($this->generateUrl('config'));
39 }
40
41 return $this->render('WallabagCoreBundle:Config:index.html.twig', array(
42 'form' => $form->createView(),
43 ));
44 }
45
46 private function getConfig()
47 {
48 $config = $this->getDoctrine()
49 ->getRepository('WallabagCoreBundle:Config')
50 ->findOneByUser($this->getUser());
51
52 if (!$config) {
53 $config = new Config($this->getUser());
54 }
55
56 return $config;
57 }
58}