3 namespace Wallabag\CoreBundle\Controller
;
5 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route
;
6 use Symfony\Bundle\FrameworkBundle\Controller\Controller
;
7 use Symfony\Component\HttpFoundation\Request
;
8 use Wallabag\CoreBundle\Entity\Config
;
9 use Wallabag\CoreBundle\Form\Type\ConfigType
;
11 class ConfigController
extends Controller
14 * @param Request $request
16 * @Route("/config", name="config")
18 * @return \Symfony\Component\HttpFoundation\Response
20 public function indexAction(Request
$request)
22 $config = $this->getConfig();
24 $form = $this->createForm(new ConfigType(), $config);
26 $form->handleRequest($request);
28 if ($form->isValid()) {
29 $em = $this->getDoctrine()->getManager();
30 $em->persist($config);
33 $this->get('session')->getFlashBag()->add(
38 return $this->redirect($this->generateUrl('config'));
41 return $this->render('WallabagCoreBundle:Config:index.html.twig', array(
42 'form' => $form->createView(),
46 private function getConfig()
48 $config = $this->getDoctrine()
49 ->getRepository('WallabagCoreBundle:Config')
50 ->findOneByUser($this->getUser());
53 $config = new Config($this->getUser());