Skip to content
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

[ResourceBundle] Search id or slug in request query strings #3548

Merged
merged 2 commits into from
Nov 11, 2015
Merged

[ResourceBundle] Search id or slug in request query strings #3548

merged 2 commits into from
Nov 11, 2015

Conversation

SebLours
Copy link
Contributor

@SebLours SebLours commented Nov 7, 2015

A POST, PUT or PATCH request like this:

{
    "country_code": "FR",
    "first_name": "First name",
    "last_name": "Last name",
    "slug": "my-slug"
}

throws a 404 response because the slug became a default search criteria.

@SebLours SebLours changed the title Search id or slug in request query strings [ResourceBundle] Search id or slug in request query strings Nov 8, 2015
@pjedrzejewski
Copy link
Member

The thing is, we may want display something by slug, which is in the request attributes. (eg. /foo/{slug})

This change works for Sylius, but in the case I mentioned above with custom resources it can be a problem. Perhaps we should look in the query AND attributes bag? What do you think? That would skip the "request" bag because it does not make sense to look there anyway.

@pjedrzejewski pjedrzejewski added this to the v0.16.0 milestone Nov 9, 2015
@SebLours
Copy link
Contributor Author

SebLours commented Nov 9, 2015

Hi Pawel,

Of course, you're right.
Now request's attributes & query are tested.

if ($request->attributes->has('slug') || $request->query->has('slug')) {
    $default = array('slug' => $request->get('slug'));
} elseif ($request->attributes->has('id') || $request->query->has('id')) {
    $default = array('id' => $request->get('id'));
} else {
    $default = array();
}

pjedrzejewski pushed a commit that referenced this pull request Nov 11, 2015
[ResourceBundle] Search id or slug in request query strings
@pjedrzejewski pjedrzejewski merged commit 575ad53 into Sylius:master Nov 11, 2015
@pjedrzejewski
Copy link
Member

Perfect, thank you very much Sébastien!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants