Use gisId to resolve Site

This commit is contained in:
Nicolò P. 2024-11-14 08:39:30 +01:00
parent 015fc0ea94
commit 028dae3d4e

View File

@ -6,11 +6,15 @@ use App\Entity\Site;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
class SiteController extends AbstractController class SiteController extends AbstractController
{ {
#[Route('/site/{id<\d+>}', name: 'app_site')] #[Route('/site/{gisId<\w+>}', name: 'app_site')]
public function index(Site $site): JsonResponse public function index(
#[MapEntity(mapping: ['gisId' => 'gisId'])]
Site $site
): JsonResponse
{ {
return $this->json([ return $this->json([
'message' => 'Request successful', 'message' => 'Request successful',