wip: first working version

This commit is contained in:
Björn Fromme
2024-11-21 18:38:41 +01:00
parent d4c4e69d09
commit bd13ae6537
24 changed files with 590 additions and 319 deletions
@@ -0,0 +1,37 @@
<?php
namespace App\Controller\Booking;
use App\BusProNet\ApiClient;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class IndexController extends AbstractController
{
public function __construct(
private readonly ApiClient $apiClient,
private readonly Security $security,
) {
}
#[Route('/bookings', name: 'app_bookings')]
#[IsGranted("ROLE_USER")]
public function index(Request $request): Response
{
$bpnUser = $request->getSession()->get('bpn_user');
if (null === $bpnUser) {
return $this->security->logout();
}
$bookings = $this->apiClient->getBookings($bpnUser->getEmail(), $bpnUser->getPassword());
return $this->render('booking/index.html.twig', [
'bookings' => $bookings->getItems(),
]);
}
}