+ // handle changing user information
+ $userForm = $this->createForm(new UserInformationType(), $user);
+ $userForm->handleRequest($request);
+
+ if ($userForm->isValid()) {
+ $em->persist($user);
+ $em->flush();
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'Information updated'
+ );
+
+ return $this->redirect($this->generateUrl('config'));
+ }
+
+ // handle rss information
+ $rssForm = $this->createForm(new RssType(), $config);
+ $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 adding new user
+ $newUser = new User();
+ $newUserForm = $this->createForm(new NewUserType(), $newUser);
+ $newUserForm->handleRequest($request);
+
+ if ($newUserForm->isValid()) {
+ $em->persist($newUser);
+
+ $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'));
+ }
+