-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing] Add a 'has' method to the RouteCollection #19270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Maybe you should add a |
Not 100% related to this PR, but never use |
@wouterj, thanks for the heads up! So, there is no way to check whether a route exists at runtime... |
@voronkovich yeah, catching the exception is knowing whether the route exists or not: use Symfony\Component\Routing\Exception\RouteNotFoundException;
try {
dump($router->generate('some_route'));
} catch (RouteNotFoundException $e) {
dump('Oh noes, route "some_route" doesn't exists!');
} |
Closing as as @wouterj mentioned, the route collection is an implementation detail that you should never use directly. |
@fabpot do you know the reason why |
@wouterj That's very old :) I think this can be deprecated so that we can remove it in 4.0. |
@wouterj the getRouteCollection was necessary for the old implementation of the router cache warming. |
This method is usefull when you want just to check whether a route exists: