Search code examples
phpzend-frameworkzend-routezend-rest

Mutiple ids on Rest Router / Zend?


I think I have the same issue as this guy - http://framework.zend.com/issues/browse/ZF-9385?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel

"If I call something like this /mod/con/123/abc on a RESTful Controller I would expect, that "123" is my ID and "abc" is something else (a secondary/subsequent ID), instead "123" its the key with "abc" as value and "id" is missing at all. The ID should not get lost here and the additional parameters ... I would prefer, that they are just numbered But at least the usual behaviour (/key1/value1/key2/value2) should start behind the id-parameter."

I need to extract the ids from the url: mycontroller.com/a/getdetails/123/234/345/456

Whereas Zend keeps the above as:

[_params:protected] => Array
    (
        [controller] => getdetails
        [action] => get
        [format] => xml
        [123] => 234
        [345] => 456
        [module] => default
    )

How can I treat 123, 234, 345 and 456 as ids? Or how do I extricate them from the URL?


Solution

  • You either needs to create custom routes or change your URL structure (easiest method) to something like

    mycontroller.com/a/getdetails/ids/123|234|345|456

    and explode on your delimiter.