| Conditions | 3 |
| Paths | 2 |
| Total Lines | 28 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function registerAction(Request $request) |
||
| 17 | { |
||
| 18 | // 1) build the form |
||
| 19 | $passwordEncoder = $this->get("security.password_encoder"); |
||
| 20 | $user = new Account(); |
||
| 21 | $form = $this->createForm(Registration::class, $user); |
||
| 22 | |||
| 23 | // 2) handle the submit (will only happen on POST) |
||
| 24 | $form->handleRequest($request); |
||
| 25 | if ($form->isSubmitted() && $form->isValid()) { |
||
| 26 | //$password = $passwordEncoder->encodePassword($user, "ap@2010"); |
||
| 27 | |||
| 28 | // 3) Encode the password (you could also do this via Doctrine listener) |
||
| 29 | $password = $passwordEncoder->encodePassword($user, $user->getPassword()); |
||
| 30 | $user->setPassword($password); |
||
| 31 | |||
| 32 | // 4) save the User! |
||
| 33 | $em = $this->getDoctrine()->getManager(); |
||
| 34 | $em->persist($user); |
||
| 35 | $em->flush(); |
||
| 36 | |||
| 37 | // ... do any other work - like sending them an email, etc |
||
| 38 | // maybe set a "flash" success message for the user |
||
| 39 | |||
| 40 | return $this->redirectToRoute('replace_with_some_route'); |
||
| 41 | } |
||
| 42 | |||
| 43 | return $this->render("@RibsAdmin/registration/registration.html", ['form' => $form->createView()]); |
||
| 44 | } |
||
| 45 | } |