+ $userManager = $this->container->get('fos_user.user_manager');
+ $user = $this->getUser();
+
+ // handle basic config detail (this form is defined as a service)
+ $configForm = $this->createForm('config', $config, array('action' => $this->generateUrl('config')));
+ $configForm->handleRequest($request);
+
+ if ($configForm->isValid()) {
+ $em->persist($config);
+ $em->flush();
+
+ // switch active theme
+ $activeTheme = $this->get('liip_theme.active_theme');
+ $activeTheme->setName($config->getTheme());
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'Config saved. Some parameters will be considered after disconnection.'
+ );
+
+ return $this->redirect($this->generateUrl('config'));
+ }
+
+ // handle changing password
+ $pwdForm = $this->createForm(new ChangePasswordType(), null, array('action' => $this->generateUrl('config').'#set4'));
+ $pwdForm->handleRequest($request);
+
+ if ($pwdForm->isValid()) {
+ $user->setPlainPassword($pwdForm->get('new_password')->getData());
+ $userManager->updateUser($user, true);
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'Password updated'
+ );
+
+ return $this->redirect($this->generateUrl('config'));
+ }
+
+ // handle changing user information
+ $userForm = $this->createForm(new UserInformationType(), $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(new RssType(), $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(new TaggingRuleType(), $taggingRule, array('action' => $this->generateUrl('config').'#set5'));
+ $newTaggingRule->handleRequest($request);