Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Routing] Allow ArrayAccess object as parameter #5999

Copy link
Copy link
Closed
@franzliedke

Description

@franzliedke
Issue body actions

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.