Closed
Description
When generating URLs, named parameters are usually passed like this:
$uri = $router->generate('blog_show', array('slug' => 'my-blog-post'));
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.