em = $em; $this->theme = $theme; $this->itemsOnPage = $itemsOnPage; $this->rssLimit = $rssLimit; $this->language = $language; $this->readingSpeed = $readingSpeed; $this->actionMarkAsRead = $actionMarkAsRead; $this->listMode = $listMode; } public static function getSubscribedEvents() { return [ // when a user register using the normal form FOSUserEvents::REGISTRATION_COMPLETED => 'createConfig', // when we manually create a user using the command line // OR when we create it from the config UI FOSUserEvents::USER_CREATED => 'createConfig', ]; } public function createConfig(UserEvent $event, $eventName = null, EventDispatcherInterface $eventDispatcher = null) { $config = new Config($event->getUser()); $config->setTheme($this->theme); $config->setItemsPerPage($this->itemsOnPage); $config->setRssLimit($this->rssLimit); $config->setLanguage($this->language); $config->setReadingSpeed($this->readingSpeed); $config->setActionMarkAsRead($this->actionMarkAsRead); $config->setListMode($this->listMode); $this->em->persist($config); $this->em->flush(); } }