Search code examples
symfonydoctrinedoctrine-odm

Symfony 4 not hydrating object with Doctrine ODM


I’m following the SF4 demo tutorial where one can define a route like /{id}/edit and SF4 will know that it needs to pass object to the method being called. E.g.

/**
 * @Route("/{id}/edit",methods={"GET", "POST"}, name="admin_site_edit")
 */
public function edit(Request $request, Site $site): ?Response
{
    // site object is hydrated with data
    echo $site->getId();
}

The problem I'm facing is with Doctrine Mongo ODM. The site object is passed correctly to the method, however the property data is empty. Furthermore I see no database calls. This got me thinking if this functionality works correctly with Doctrine ODM, as I've tried it with ORM and it worked perfectly. Or am I missing something obvious?


Solution

  • It seems that Doctrine ODM doesn't work out of the box with the param converter:

    paramconverter not converting parameters