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\Command;
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\FOSUserEvents;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\ArrayInput;
@ -236,14 +238,9 @@ class InstallCommand extends ContainerAwareCommand
$em->persist($user);
$config = new Config($user);
$config->setTheme($this->getContainer()->getParameter('wallabag_core.theme'));
$config->setItemsPerPage($this->getContainer()->getParameter('wallabag_core.items_on_page'));
$config->setRssLimit($this->getContainer()->getParameter('wallabag_core.rss_limit'));
$config->setReadingSpeed($this->getContainer()->getParameter('wallabag_core.reading_speed'));
$config->setLanguage($this->getContainer()->getParameter('wallabag_core.language'));
$em->persist($config);
// dispatch a created event so the associated config will be created
$event = new UserEvent($user);
$this->getContainer()->get('event_dispatcher')->dispatch(FOSUserEvents::USER_CREATED, $event);
$this->defaultOutput->writeln('');