You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the routing system, we have the possibility to use variables (e.g. Route::get('/{draw}', ...)). We can also define a pattern to match those variables with Route::pattern('draw', ...).
In my routes I have both {draw:id} and {draw:hash} (using the HashId system) but I can't set a Route::pattern for the hash one.
If I set Route::pattern('draw', ...) it's defined for boths fields (id and hash) but if I define with Route::pattern('draw:hash', ...) it's ignored.
Upon further analyze, Symfony RouteCompiler uses \w+ ([A-Za-z0-9_]+) to get the variable name in the actual route (/{draw:hash}) so it's totally ignoring the field part.
The reason I'm using the field selector is to automatically use the route model binding (Draw::resolveRouteBinding) so I don't want to use custom names like drawId and drawHash.
Not sure how to implement that. Should we ask Symfony to add the ":" is the RouteCompiler regex or have a way to specify the field in the pattern match?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
In the routing system, we have the possibility to use variables (e.g. Route::get('/{draw}', ...)). We can also define a pattern to match those variables with Route::pattern('draw', ...).
In my routes I have both {draw:id} and {draw:hash} (using the HashId system) but I can't set a Route::pattern for the hash one.
If I set Route::pattern('draw', ...) it's defined for boths fields (id and hash) but if I define with Route::pattern('draw:hash', ...) it's ignored.
Upon further analyze, Symfony RouteCompiler uses \w+ ([A-Za-z0-9_]+) to get the variable name in the actual route (/{draw:hash}) so it's totally ignoring the field part.
The reason I'm using the field selector is to automatically use the route model binding (Draw::resolveRouteBinding) so I don't want to use custom names like drawId and drawHash.
Not sure how to implement that. Should we ask Symfony to add the ":" is the RouteCompiler regex or have a way to specify the field in the pattern match?
Thanks
Korko
Beta Was this translation helpful? Give feedback.
All reactions