|
@@ -4,59 +4,13 @@ namespace Muzich\AdminBundle\Controller\Admin_user;
|
4
|
4
|
|
5
|
5
|
use Admingenerated\MuzichAdminBundle\BaseAdmin_userController\EditController as BaseEditController;
|
6
|
6
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
|
7
|
+use Symfony\Component\Form\Form;
|
|
8
|
+use Muzich\CoreBundle\Entity\User;
|
7
|
9
|
|
8
|
10
|
class EditController extends BaseEditController
|
9
|
11
|
{
|
10
|
|
-
|
11
|
|
- protected function getUserContext($pk)
|
|
12
|
+ public function preSave(Form $form, User $User)
|
12
|
13
|
{
|
13
|
|
- $User = $this->getObject($pk);
|
14
|
|
- if (!$User) {
|
15
|
|
- throw new NotFoundHttpException("The Muzich\CoreBundle\Entity\User with id $pk can't be found");
|
16
|
|
- }
|
17
|
|
- return $User;
|
|
14
|
+ $this->container->get('fos_user.user_manager')->updateUser($User);
|
18
|
15
|
}
|
19
|
|
-
|
20
|
|
- protected function getFormPassword($User)
|
21
|
|
- {
|
22
|
|
- return $this->createFormBuilder($User)
|
23
|
|
- ->add('plain_password', 'text')
|
24
|
|
- ->getForm();
|
25
|
|
- }
|
26
|
|
-
|
27
|
|
- public function passwordAction($pk)
|
28
|
|
- {
|
29
|
|
- $User = $this->getUserContext($pk);
|
30
|
|
- $form = $this->getFormPassword($User);
|
31
|
|
-
|
32
|
|
- return $this->render('MuzichAdminBundle:Admin_userEdit:password.html.twig', array(
|
33
|
|
- "User" => $User,
|
34
|
|
- "form" => $form->createView(),
|
35
|
|
- ));
|
36
|
|
- }
|
37
|
|
-
|
38
|
|
- public function passwordUpdateAction($pk)
|
39
|
|
- {
|
40
|
|
- $User = $this->getUserContext($pk);
|
41
|
|
- $form = $this->getFormPassword($User);
|
42
|
|
- $form->bind($this->getRequest());
|
43
|
|
-
|
44
|
|
- if ($form->isValid())
|
45
|
|
- {
|
46
|
|
- $this->container->get('fos_user.user_manager')->updateUser($User);
|
47
|
|
- $em = $this->getDoctrine()->getManager();
|
48
|
|
- $em->persist($User);
|
49
|
|
- $em->flush();
|
50
|
|
-
|
51
|
|
- $this->get('session')->setFlash('success', $this->get('translator')->trans("object.edit.success", array(), 'Admingenerator') );
|
52
|
|
- return new RedirectResponse($this->generateUrl("Muzich_AdminBundle_Admin_user_list" ));
|
53
|
|
- }
|
54
|
|
-
|
55
|
|
- $this->get('session')->setFlash('error', $this->get('translator')->trans("object.edit.error", array(), 'Admingenerator') );
|
56
|
|
- return $this->render('MuzichAdminBundle:Admin_userEdit:password.html.twig', array(
|
57
|
|
- "User" => $User,
|
58
|
|
- "form" => $form->createView(),
|
59
|
|
- ));
|
60
|
|
- }
|
61
|
|
-
|
62
|
16
|
}
|