diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/ConfigController.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index b3236e3c..aedbc999 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php | |||
@@ -6,9 +6,11 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | |||
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
7 | use Symfony\Component\HttpFoundation\Request; | 7 | use Symfony\Component\HttpFoundation\Request; |
8 | use Wallabag\CoreBundle\Entity\Config; | 8 | use Wallabag\CoreBundle\Entity\Config; |
9 | use Wallabag\CoreBundle\Entity\User; | ||
9 | use Wallabag\CoreBundle\Form\Type\ConfigType; | 10 | use Wallabag\CoreBundle\Form\Type\ConfigType; |
10 | use Wallabag\CoreBundle\Form\Type\ChangePasswordType; | 11 | use Wallabag\CoreBundle\Form\Type\ChangePasswordType; |
11 | use Wallabag\CoreBundle\Form\Type\UserType; | 12 | use Wallabag\CoreBundle\Form\Type\UserType; |
13 | use Wallabag\CoreBundle\Form\Type\NewUserType; | ||
12 | 14 | ||
13 | class ConfigController extends Controller | 15 | class ConfigController extends Controller |
14 | { | 16 | { |
@@ -72,10 +74,28 @@ class ConfigController extends Controller | |||
72 | return $this->redirect($this->generateUrl('config')); | 74 | return $this->redirect($this->generateUrl('config')); |
73 | } | 75 | } |
74 | 76 | ||
77 | // handle adding new user | ||
78 | $newUser = new User(); | ||
79 | $newUserForm = $this->createForm(new NewUserType(), $newUser); | ||
80 | $newUserForm->handleRequest($request); | ||
81 | |||
82 | if ($newUserForm->isValid()) { | ||
83 | $em->persist($newUser); | ||
84 | $em->flush(); | ||
85 | |||
86 | $this->get('session')->getFlashBag()->add( | ||
87 | 'notice', | ||
88 | sprintf('User "%s" added', $newUser->getUsername()) | ||
89 | ); | ||
90 | |||
91 | return $this->redirect($this->generateUrl('config')); | ||
92 | } | ||
93 | |||
75 | return $this->render('WallabagCoreBundle:Config:index.html.twig', array( | 94 | return $this->render('WallabagCoreBundle:Config:index.html.twig', array( |
76 | 'configForm' => $configForm->createView(), | 95 | 'configForm' => $configForm->createView(), |
77 | 'pwdForm' => $pwdForm->createView(), | 96 | 'pwdForm' => $pwdForm->createView(), |
78 | 'userForm' => $userForm->createView(), | 97 | 'userForm' => $userForm->createView(), |
98 | 'newUserForm' => $newUserForm->createView(), | ||
79 | )); | 99 | )); |
80 | } | 100 | } |
81 | 101 | ||