У меня есть метод контроллера Symfony, который извлекает значок по его матрице (определенному идентификатору):
Код: Выделить всё
php
/**
* @Route("/badges_search/{matricule}", name="app_search_badge_matricule", methods={"GET"})
*/
public function searchBadgeByMatricule(SerializerInterface $serializer, BadgeRepository $badgeRepository, string $matricule): Response
{
$badge = $badgeRepository->findOneBy(['matricule' => $matricule]);
if (!$badge) {
return new Response(null, 404);
}
$badgeSerialize = $serializer->serialize($badge, 'json');
return new Response($badgeSerialize, 200, ['content-type' => 'application/json']);
}
Вот мой класс значка
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/78667239/api-platform-documentation-issue-incorrectly-treating-route-parameter-as-requir[/url]