2021-04-22 17:44:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
2021-04-28 00:15:13 +02:00
|
|
|
use App\Entity\Offering;
|
|
|
|
use App\Form\OfferingFormType;
|
2021-04-26 17:31:24 +02:00
|
|
|
use App\Repository\OfferingRepository;
|
|
|
|
|
2021-04-22 17:44:16 +02:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
2021-04-26 17:31:24 +02:00
|
|
|
use Twig\Environment;
|
2021-04-22 17:44:16 +02:00
|
|
|
|
|
|
|
class AppController extends AbstractController
|
|
|
|
{
|
2021-04-26 17:31:24 +02:00
|
|
|
#[Route('/', name: 'homepage')]
|
|
|
|
public function index(Environment $twig, OfferingRepository $offeringRepository): Response
|
2021-04-22 17:44:16 +02:00
|
|
|
{
|
2021-04-26 17:31:24 +02:00
|
|
|
return new Response($twig->render('app/index.html.twig', [
|
|
|
|
'offerings' => $offeringRepository->findAll(),
|
|
|
|
]));
|
2021-04-22 17:44:16 +02:00
|
|
|
}
|
2021-04-23 15:06:41 +02:00
|
|
|
|
|
|
|
#[Route('/user', name: 'user_page')]
|
|
|
|
public function user(): Response
|
|
|
|
{
|
2021-04-26 17:31:24 +02:00
|
|
|
return $this->render('app/user.html.twig', [
|
2021-04-23 15:06:41 +02:00
|
|
|
'user' => $this->getUser(),
|
|
|
|
]);
|
|
|
|
}
|
2021-04-28 00:15:13 +02:00
|
|
|
|
|
|
|
#[Route('/new', name: 'new_listing')]
|
|
|
|
public function new_listing(): Response
|
|
|
|
{
|
|
|
|
$offering = new Offering();
|
|
|
|
$form = $this->createForm(OfferingFormType::class, $offering);
|
|
|
|
|
|
|
|
|
|
|
|
return $this->render('app/new_listing.html.twig', [
|
|
|
|
'user' => $this->getUser(),
|
|
|
|
'offering_form' => $form->createView(),
|
|
|
|
]);
|
|
|
|
}
|
2021-04-22 17:44:16 +02:00
|
|
|
}
|