-
Notifications
You must be signed in to change notification settings - Fork 345
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
Redirect to last available page, if a non existent page-number was requested? #477
Comments
Hello :) |
Hello will be a nice improvment ;) |
Hi, I am not sure where and how this should be implemented within the existing code. And how to make this configurable to make it only available, when it is correctly handled. Existing applications must listen to such a RedirectException and handle it correctly, so this cannot be enabled by default, although the current default behavior of the case also isn't very graceful (throwing a 404). So it should't be an enable-and-forget-feature. Or, a I suggested, the paginator could do the redirect on its own. Doesn't sound like a clean solution. Any thoughts on this? Should the Paginator respond with a custom RedirectException that must be handled by the application? Where and how could that be implemented. I am not that familiar with the Paginator's codebase. |
@spackmat it could be implemented with a custom Exception inside the library, something like |
Fixed in related PR |
Hi,
in my application, I implemented a graceful handling of the situation, when a non existant (too high) page number was requested (e.g. when one changes the perPage-value on the last page). In that case, I return a redirect to the last available page. This looks like this:
This boilerplate is used in all my controllers and I want to abstract this check. For now, I would call a static utility function (or a service-method) in my controllers, which throws a (custom) RedirectException in that case. Like this one:
For details of that custom redirectException, see https://www.trisoft.ro/blog/56-symfony-redirecting-from-outside-the-controller
My question is now: Wouldn't that be a nice feature of the Paginator itself? Maybe configureable? To perform a redirect (preserving all other request-parameters, but the page number) on its own, when a non available page is called?
The text was updated successfully, but these errors were encountered: