2018-06-20 23:37:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
2018-06-25 01:02:27 +00:00
|
|
|
use App\Form\LoginType;
|
2018-06-20 23:37:35 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
2018-06-25 01:02:27 +00:00
|
|
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|
|
|
use Symfony\Component\Form\FormInterface;
|
2018-06-22 19:45:17 +00:00
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
2018-06-20 23:37:35 +00:00
|
|
|
|
|
|
|
class MainController extends Controller
|
|
|
|
{
|
2018-06-25 01:02:27 +00:00
|
|
|
public function index(): Response
|
2018-06-20 23:37:35 +00:00
|
|
|
{
|
|
|
|
return $this->render('index.html.twig', [
|
2018-06-25 01:02:27 +00:00
|
|
|
'loginForm' => $this->createLoginForm('')->createView(),
|
2018-06-20 23:37:35 +00:00
|
|
|
]);
|
|
|
|
}
|
2018-06-25 01:02:27 +00:00
|
|
|
|
|
|
|
private function createLoginForm(string $username): FormInterface
|
|
|
|
{
|
|
|
|
$form = $this->createForm(LoginType::class, null, [
|
|
|
|
'action' => $this->generateUrl('user_login'),
|
|
|
|
]);
|
|
|
|
$form->get('_username')->setData($username);
|
|
|
|
$form->add('submit', SubmitType::class);
|
|
|
|
|
|
|
|
return $form;
|
|
|
|
}
|
2018-06-20 23:37:35 +00:00
|
|
|
}
|