use Wallabag\CoreBundle\Entity\Config;
use Wallabag\CoreBundle\Form\Type\ConfigType;
use Wallabag\CoreBundle\Form\Type\ChangePasswordType;
+use Wallabag\CoreBundle\Form\Type\UserType;
class ConfigController extends Controller
{
{
$em = $this->getDoctrine()->getManager();
$config = $this->getConfig();
+ $user = $this->getUser();
// handle basic config detail
$configForm = $this->createForm(new ConfigType(), $config);
$configForm->handleRequest($request);
if ($configForm->isValid()) {
-
$em->persist($config);
$em->flush();
$pwdForm->handleRequest($request);
if ($pwdForm->isValid()) {
- $user = $this->getUser();
$user->setPassword($pwdForm->get('new_password')->getData());
$em->persist($user);
$em->flush();
return $this->redirect($this->generateUrl('config'));
}
+ // handle changing user information
+ $userForm = $this->createForm(new UserType(), $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'));
+ }
+
return $this->render('WallabagCoreBundle:Config:index.html.twig', array(
'configForm' => $configForm->createView(),
'pwdForm' => $pwdForm->createView(),
+ 'userForm' => $userForm->createView(),
));
}