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
It would be cool if one could pass an object that implements the ArrayAccess interface, too. That would make generating routes for models incredibly easy (and allow for changing the URL parameters without changing the places where the URLs are generated).
Something like this:
$uri = $router->generate('blog_show', $post);
Quite possibly the current implementation loops through the array and then tries to replace the appropriate placeholder if it exists. For this to work, that implementation would obviously have to be reversed - take the route, search for placeholders and then look for the corresponding parameters.
Not sure, maybe this is already possible, I wasn't very successful digging through the code.
The text was updated successfully, but these errors were encountered:
Your feature idea is right and it was intented to support using objects as parameter (object routes) from the beginning. We just need a common approach to it. But you suggestion using ArrayAccess is only half of a solution because you would not be able to add extra paramters that are not placeholders to the query string anymore.
So instead we should define an interface like Routable that defines getParameters which objects must implement to expose their parameters.
When generating URLs, named parameters are usually passed like this:
It would be cool if one could pass an object that implements the
ArrayAccess
interface, too. That would make generating routes for models incredibly easy (and allow for changing the URL parameters without changing the places where the URLs are generated).Something like this:
Quite possibly the current implementation loops through the array and then tries to replace the appropriate placeholder if it exists. For this to work, that implementation would obviously have to be reversed - take the route, search for placeholders and then look for the corresponding parameters.
Not sure, maybe this is already possible, I wasn't very successful digging through the code.
The text was updated successfully, but these errors were encountered: