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.php18
-rw-r--r--src/Wallabag/CoreBundle/Controller/ExceptionController.php40
2 files changed, 47 insertions, 11 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 4f75511b..75a9af0b 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -2,6 +2,8 @@
2 2
3namespace Wallabag\CoreBundle\Controller; 3namespace Wallabag\CoreBundle\Controller;
4 4
5use FOS\UserBundle\Event\UserEvent;
6use FOS\UserBundle\FOSUserEvents;
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller; 8use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\JsonResponse; 9use Symfony\Component\HttpFoundation\JsonResponse;
@@ -133,18 +135,11 @@ class ConfigController extends Controller
133 $newUserForm->handleRequest($request); 135 $newUserForm->handleRequest($request);
134 136
135 if ($newUserForm->isValid() && $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) { 137 if ($newUserForm->isValid() && $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) {
136 $userManager->updateUser($newUser, true); 138 $userManager->updateUser($newUser);
137 139
138 $config = new Config($newUser); 140 // dispatch a created event so the associated config will be created
139 $config->setTheme($this->getParameter('wallabag_core.theme')); 141 $event = new UserEvent($newUser, $request);
140 $config->setItemsPerPage($this->getParameter('wallabag_core.items_on_page')); 142 $this->get('event_dispatcher')->dispatch(FOSUserEvents::USER_CREATED, $event);
141 $config->setRssLimit($this->getParameter('wallabag_core.rss_limit'));
142 $config->setLanguage($this->getParameter('wallabag_core.language'));
143 $config->setReadingSpeed($this->getParameter('wallabag_core.reading_speed'));
144
145 $em->persist($config);
146
147 $em->flush();
148 143
149 $this->get('session')->getFlashBag()->add( 144 $this->get('session')->getFlashBag()->add(
150 'notice', 145 'notice',
@@ -238,6 +233,7 @@ class ConfigController extends Controller
238 ->getRepository('WallabagCoreBundle:Config') 233 ->getRepository('WallabagCoreBundle:Config')
239 ->findOneByUser($this->getUser()); 234 ->findOneByUser($this->getUser());
240 235
236 // should NEVER HAPPEN ...
241 if (!$config) { 237 if (!$config) {
242 $config = new Config($this->getUser()); 238 $config = new Config($this->getUser());
243 } 239 }
diff --git a/src/Wallabag/CoreBundle/Controller/ExceptionController.php b/src/Wallabag/CoreBundle/Controller/ExceptionController.php
new file mode 100644
index 00000000..abfa9c2f
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Controller/ExceptionController.php
@@ -0,0 +1,40 @@
1<?php
2
3namespace Wallabag\CoreBundle\Controller;
4
5use Symfony\Bundle\TwigBundle\Controller\ExceptionController as BaseExceptionController;
6use Symfony\Component\HttpFoundation\Request;
7
8/**
9 * This controller allow us to customize the error template.
10 * The only modified line from the parent template is for "WallabagCoreBundle".
11 */
12class ExceptionController extends BaseExceptionController
13{
14 protected function findTemplate(Request $request, $format, $code, $showException)
15 {
16 $name = $showException ? 'exception' : 'error';
17 if ($showException && 'html' == $format) {
18 $name = 'exception_full';
19 }
20
21 // For error pages, try to find a template for the specific HTTP status code and format
22 if (!$showException) {
23 $template = sprintf('WallabagCoreBundle:Exception:%s.%s.twig', $name, $format);
24 if ($this->templateExists($template)) {
25 return $template;
26 }
27 }
28
29 // try to find a template for the given format
30 $template = sprintf('@Twig/Exception/%s.%s.twig', $name, $format);
31 if ($this->templateExists($template)) {
32 return $template;
33 }
34
35 // default to a generic HTML exception
36 $request->setRequestFormat('html');
37
38 return sprintf('@Twig/Exception/%s.html.twig', $showException ? 'exception_full' : $name);
39 }
40}