こんにちは、login.php コードにアクセスしたいのですが、最初に / (ホーム) エラーにリダイレクトされました。
私は1つのコントローラーとそのコードを持っています
/**
* @Route("/{champ}", name="home", defaults={"champ" = 1})
*/
public function mainAction(Request $request,champion $champ)
{
$user = $this->getUser();
$form = $this->createForm(UserType::class, $user);
$champi = new champion();;
$form2 = $this->createForm(ChampionType::class, $champi);
$form3 = $this->createForm(ChampionsType::class, $champ);
$form4 = $this->createForm(ChampionTypes::class, $champ);
$form2->handleRequest($request);
$form->handleRequest($request);
$form3->handleRequest($request);
$form4->handleRequest($request);
if ($form->isValid() && $form->isSubmitted()) {
$password = $this->get('security.password_encoder')
->encodePassword($user, $user->getPlainPassword());
$user->setPassword($password);
$em = $this->getDoctrine()->getEntityManager();
$em->persist($user);
$em->flush();
$this->addFlash("success", '');
}
if ($form2->isValid() && $form2->isSubmitted()) {
$em = $this->getDoctrine()->getEntityManager();
$em->persist($champi);
$em->flush();
$this->addFlash("success", '');
}
if ($form3->isValid() && $form3->isSubmitted()) {
$em = $this->getDoctrine()->getEntityManager();
$em->persist($champ);
$em->flush();
$this->addFlash("success", '');
}
if ($form4->isValid() && $form4->isSubmitted()) {
$em = $this->getDoctrine()->getEntityManager();
$em->remove($champ);
$em->flush();
$this->addFlash("success", '');
}
$champ = $this->getDoctrine()
->getRepository('AppBundle:champion')
->findAll();
$champs = $this->getDoctrine()
->getRepository('AppBundle:champion')
->findAll();
return $this->render('AppBundle:uzduotis:index.html.twig', [
'form' => $form->createView(),
'form2' => $form2->createView(),
'form3' => $form3->createView(),
'form4' => $form4->createView(),
'user' => $user,
'champions' => $champ
]);
}
/**
* @Route("/login", name="authentication_login")
* @Method({"GET","POST"})
*/
public function loginActionAction(Request $request)
{
$authenticationUtils = $this->get('security.authentication_utils');
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('AppBundle:uzduotis:login.html.twig', array(
'last_username' => $lastUsername,
'error' => $error,
));
}
localhost:8000/login にアクセスしようとしましたが、それでもホームにリダイレクトされました。