G
G
gitdev2021-01-18 20:14:17
symfony
gitdev, 2021-01-18 20:14:17

How in Symfony 5.2 to bind an Entity with a custom unique parameter passed in the controller?

there is a url field, you need to get the Entity by this field (not by id).
That is, the selection must be performed by the Proposition url

/**
     * @Route("/present/{url}", name="cv_present", methods={"GET","POST"}, requirements={"url"="[a-z0-9-]+"})
     * @param Proposition $proposition
     * @param Request $request
     * @param CVService $CVService
     * @return Response
     */
    public function present(Proposition $proposition, Request $request, CVService $CVService): Response
    {

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Derepko, 2021-01-18
@gitdev

https://symfony.com/doc/current/doctrine.html#auto...
at the end of the section there is a link to ParamConverter
Here is an example: https://github.com/sensiolabs/SensioFrameworkExtra...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question