mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-06 05:19:43 +00:00
Use [#MapEntity()] attribute to inject entity into method + for now set controller_resolver.auto_mapping to true
This commit is contained in:
@@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Repository\GeographicalUnitRepositoryInterface;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
@@ -27,7 +28,7 @@ class GeographicalUnitByAddressApiController
|
||||
public function __construct(private readonly PaginatorFactory $paginatorFactory, private readonly GeographicalUnitRepositoryInterface $geographicalUnitRepository, private readonly Security $security, private readonly SerializerInterface $serializer) {}
|
||||
|
||||
#[Route(path: '/api/1.0/main/geographical-unit/by-address/{id}.{_format}', requirements: ['_format' => 'json'])]
|
||||
public function getGeographicalUnitCoveringAddress(Address $address): JsonResponse
|
||||
public function getGeographicalUnitCoveringAddress(#[MapEntity(id: 'id')] Address $address): JsonResponse
|
||||
{
|
||||
if (!$this->security->isGranted('ROLE_USER')) {
|
||||
throw new AccessDeniedHttpException();
|
||||
|
Reference in New Issue
Block a user