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

Duplicate parameters in the URI should not overwrite one another #3

Closed
AP-Hunt opened this issue May 9, 2014 · 1 comment
Closed

Comments

@AP-Hunt
Copy link
Owner

AP-Hunt commented May 9, 2014

A URI with duplicate parameter names such as /organisation/<id>/teams/<id>, with the relevant resource definitions, will come out with only 1 id parameter, with the value of the last matched parameter.

This is an issue with using standard parameter schemes more than once in a resource hierarchy. It can be replicated using the following resource definitions and the uri /parent/1/child/1

new Resource("Parent", "/parent", new Scheme\Id(), array(
    new Resource("Child", "/child", new Scheme\Id())
);

Controller methods currently expect a hash of parameter values keyed on parameter names, which are defined in the parameter scheme. My current thought is this may be resolvable by creating some kind of unique name combining the resource name and the parameter name (eg Child_id). Generated names would need to be predictable and consistent, and not require any configuration at all.

An alternative could be to allow this behaviour to continue, and instead try enforce the uniqueness of parameter names in the parameter scheme. For example: new Resource("Parent", "/parent", new Scheme\Id("parent_id"));

AP-Hunt added a commit that referenced this issue May 11, 2014
…e matched at all because parameters were being recreated at every call to `\Nap\Resource\Parameter\ParameterScheme::getParameters`
@AP-Hunt
Copy link
Owner Author

AP-Hunt commented May 19, 2014

An alternative proposal here would be to alter controllers to expect some object which can retrieve parameters based on the resource name and parameter name. For example:

clas MyController implement \Nap\Controller\NapControllerInterface
{
    // ...
    public function get($request, \Nap\SomeType $params)
    {
        $parentId = $params->get("parent/id");
        $childId = $params->get("child/id");
    }
}

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

No branches or pull requests

1 participant