If I have my routing set up like this:
'foo' => array (
'type' => 'segment',
'options' => array (
'route' => '/:foo',
'defaults' => array (
'controller' => 'Application\Controller\Foo',
'action' => 'foo'
)
),
'may_terminate' => true,
'child_routes' => array (
'bar' => array (
'type' => 'segment',
'options' => array (
'route' => '/:bar[/:someMoreData]',
'defaults' => array(
'controller' => 'Application\Controller\Foo',
'action' => 'bar'
)
),
'may_terminate' => true
)
)
)
And I have URLs like this: http://127.0.0.1/foo/bar/someParam(123)/someOtherParam(456,789)/myParam(1,2,3)
where the order of the three (or possibly even more params) is completely random and their values, encased in brackets, can also be completely random.
How would I need to adjust my routing to access every param and its value in my Controller using $this->params('myParam')
or similar?
Basically exactly like I would be able to using a query string: http://127.0.0.1/foo/bar?myParam=1,2,3&otherParam...
Or am I misunderstanding something here?
Note: I can't use query strings.
Why can't you use query params for your use case? It would be much cleaner imo.
Anyway you can use the fromRoute()
method without any arguments to retrieve all parameters.
public function myAction()
{
$params = $this->params()->fromRoute();
}