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
Assume you can archive BlogPost instances, and you need to use different route names for archived blog posts. For example, the blog_detail route might be at /blog/{slug}, but blog_archived is at /archive/{slug}.
It would be nice if you could still write {{ object_route(post, 'detail') }} in Twig and make the object route figure out whether to use blog_detail or blog_archived.
To make this possible, we could allow to omit the name configuration parameter from @ObjectRoute under the condition that the set of parameters obtained through params contains a _route param. If that is the case, use _route as the route name.
We should fail if either name is provided and a _route is returned, or if neither one is present.
Admittedly, the motivating use case would require that the BlogPost object itself can make the distinction:
Assume you can archive
BlogPost
instances, and you need to use different route names for archived blog posts. For example, theblog_detail
route might be at/blog/{slug}
, butblog_archived
is at/archive/{slug}
.It would be nice if you could still write
{{ object_route(post, 'detail') }}
in Twig and make the object route figure out whether to useblog_detail
orblog_archived
.To make this possible, we could allow to omit the
name
configuration parameter from@ObjectRoute
under the condition that the set of parameters obtained throughparams
contains a_route
param. If that is the case, use_route
as the route name.We should fail if either
name
is provided and a_route
is returned, or if neither one is present.Admittedly, the motivating use case would require that the
BlogPost
object itself can make the distinction:@ObjectRoute(type="detail", params={"_route": "routeName"})
-> callsBlogPost::getRouteName()
However, in combination with #12 the full flexibility could be put into the
ObjectRoute
declaration.The text was updated successfully, but these errors were encountered: