1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-07-17 17:08:37 +00:00

Create user config in one place

Using a listener, user config is now created when a user:

- is created from the command line
- register (with or without email confirmation)
- is created from the config panel
This commit is contained in:
Jeremy Benoist 2016-09-30 21:01:36 +02:00
parent 114c55c0a6
commit ca17abce2d
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
6 changed files with 51 additions and 43 deletions

View file

@ -2,6 +2,8 @@
namespace Wallabag\CoreBundle\Controller;
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\FOSUserEvents;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
@ -133,18 +135,11 @@ class ConfigController extends Controller
$newUserForm->handleRequest($request);
if ($newUserForm->isValid() && $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) {
$userManager->updateUser($newUser, true);
$userManager->updateUser($newUser);
$config = new Config($newUser);
$config->setTheme($this->getParameter('wallabag_core.theme'));
$config->setItemsPerPage($this->getParameter('wallabag_core.items_on_page'));
$config->setRssLimit($this->getParameter('wallabag_core.rss_limit'));
$config->setLanguage($this->getParameter('wallabag_core.language'));
$config->setReadingSpeed($this->getParameter('wallabag_core.reading_speed'));
$em->persist($config);
$em->flush();
// dispatch a created event so the associated config will be created
$event = new UserEvent($newUser, $request);
$this->get('event_dispatcher')->dispatch(FOSUserEvents::USER_CREATED, $event);
$this->get('session')->getFlashBag()->add(
'notice',
@ -238,6 +233,7 @@ class ConfigController extends Controller
->getRepository('WallabagCoreBundle:Config')
->findOneByUser($this->getUser());
// should NEVER HAPPEN ...
if (!$config) {
$config = new Config($this->getUser());
}