Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace ImmoWebBundle\Controller;
- use ImmoWebBundle\Controller;
- use ImmoWebBundle\Entity\Person;
- use ImmoWebBundle\Form\PersonType;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
- use Symfony\Component\HttpFoundation\Request;
- class IndexController extends Controller
- {
- /**
- * @Route("/", name="home")
- */
- public function indexAction(Request $request)
- {
- // replace this example code with whatever you need
- return $this->renderFrontend('index');
- }
- /**
- * @Route("/register", name="register")
- */
- public function registerAction(Request $request)
- {
- $person = new Person();
- $form = $this->createForm(PersonType::class, $person);
- $form->handleRequest($request);
- if ($form->isSubmitted() && $form->isValid()) {
- $password = $this->get('security.password_encoder')
- ->encodePassword($person, $person->getPlainPassword());
- $person->setPassword($password);
- $em = $this->getDoctrine()->getManager();
- $em->persist($person);
- $em->flush();
- return $this->redirectToRoute('home');
- }
- return $this->renderFrontend(
- 'register',
- ['form' => $form->createView()]
- );
- }
- /**
- * @Route("/login", name="login")
- */
- public function loginAction(Request $request)
- {
- $authenticationUtils = $this->get('security.authentication_utils');
- $error = $authenticationUtils->getLastAuthenticationError();
- $lastUsername = $authenticationUtils->getLastUsername();
- return $this->renderFrontend('login', [
- 'last_username' => $lastUsername,
- 'error' => $error
- ]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement