Symfony entity parameter converter doesn't get route items correctly
P粉885562567
2023-08-28 22:55:25
<p>I have a route that needs to get categories and subcategories. The route is in the following form: </p>
<pre class="brush:php;toolbar:false;">#[Route('/{slug}/{subSlug}', name: 'subcategory')]
#[Entity('category', expr: 'repository.findOneBySlug(slug)')]
#[Entity('subcategory', expr: 'repository.findOneBySlug(subSlug)')]
public function subcat(Category $cat, Subcategory $sub): Response</pre>
<p>I tried to access <code>/mtg/dmr</code>, but I got a 404 Object not found error, caused by @ParamConverter.
When I look in the Doctrine log, the system is looking in the correct table, but for both it is looking for <code>mtg</code> instead of first looking for <code>mtg</code> and then < code>dmr</code>. Any ideas what's going on? </p>
DOC example:
So, in your case you must have: