blob: f48a9cb19ad506cd8f2531cd9755e453e4c7cc30 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
<?php
namespace Wallabag\CoreBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\CoreBundle\Form\Type\ConfigType;
class ConfigController extends Controller
{
/**
* @param Request $request
*
* @Route("/config", name="config")
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function indexAction(Request $request)
{
$config = $this->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;
}
}
|