+ // handle changing user information
+ $userForm = $this->createForm(UserInformationType::class, $user, array(
+ 'validation_groups' => array('Profile'),
+ 'action' => $this->generateUrl('config').'#set3',
+ ));
+ $userForm->handleRequest($request);
+
+ if ($userForm->isValid()) {
+ $userManager->updateUser($user, true);
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'Information updated'
+ );
+
+ return $this->redirect($this->generateUrl('config'));
+ }
+
+ // handle rss information
+ $rssForm = $this->createForm(RssType::class, $config, array('action' => $this->generateUrl('config').'#set2'));
+ $rssForm->handleRequest($request);
+
+ if ($rssForm->isValid()) {
+ $em->persist($config);
+ $em->flush();
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'RSS information updated'
+ );
+
+ return $this->redirect($this->generateUrl('config'));
+ }
+
+ // handle tagging rule
+ $taggingRule = new TaggingRule();
+ $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, array('action' => $this->generateUrl('config').'#set5'));
+ $newTaggingRule->handleRequest($request);
+
+ if ($newTaggingRule->isValid()) {
+ $taggingRule->setConfig($config);
+ $em->persist($taggingRule);
+ $em->flush();
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'Tagging rules updated'
+ );
+
+ return $this->redirect($this->generateUrl('config'));
+ }
+
+ // handle adding new user
+ $newUser = $userManager->createUser();
+ // enable created user by default
+ $newUser->setEnabled(true);
+ $newUserForm = $this->createForm(NewUserType::class, $newUser, array(
+ 'validation_groups' => array('Profile'),
+ 'action' => $this->generateUrl('config').'#set5',
+ ));
+ $newUserForm->handleRequest($request);
+
+ if ($newUserForm->isValid() && $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) {
+ $userManager->updateUser($newUser, true);
+
+ $config = new Config($newUser);
+ $config->setTheme($this->container->getParameter('theme'));
+ $config->setItemsPerPage($this->container->getParameter('items_on_page'));
+ $config->setRssLimit($this->container->getParameter('rss_limit'));
+ $config->setLanguage($this->container->getParameter('language'));
+
+ $em->persist($config);
+
+ $em->flush();
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ sprintf('User "%s" added', $newUser->getUsername())
+ );
+
+ return $this->redirect($this->generateUrl('config'));
+ }
+