0

I am generating url addres with zend url helper with additional /query, as I found here. In configuration file I have setup router like that:

'my_name' => array(
                'type' => 'segment',
                'options' => array(
                    'route'    => '/my_name/:id/some_action[/:id2]',
                    'constraints' => array(
                        'id' => '[0-9]+',
                        'id2' => '[0-9]+',
                    ),
                    'defaults' => array(
                        'controller' => 'MyController',
                    ),
                ),
                'may_terminate' => true,
                'child_routes'  => array(
                    'query' => array(
                        'type' => 'Query',
                        'options' => array(
                            'defaults' => array(
                            )
                        )
                    ),
                ),
            ),

I receive generated link, that looks like that:

http://my_address/my_name/:id/some_action/?controller=MyController&limit=1&action=get&offset=2

What I want to do is to remove controller and action params, which I din't set, and to display only params provided by myself.

Is there any option to set in in router config? Or maybe there is any other way to get what I want?

Community
  • 1
  • 1
acabala
  • 149
  • 1
  • 14

1 Answers1

0

You don't have an action specified in either your route, or your defaults. You need to be able to identify which action (method) is to be called when the route is matched.

'route'    => '/my_name/:id/:action[/:id2]', // allow action passed thru
'constraints' => array(
     'id' => '[0-9]+',
     'id2' => '[0-9]+',
 ),
 'defaults' => array(
    'controller' => 'MyController',
    'action'     => 'some_action', // or specify a default action to use
 ),
Andrew
  • 12,617
  • 1
  • 34
  • 48
  • It is that I use `AbstractRestfulController` and proper actions are selected based on HTTP methods and URL part (`some_action`). That way I think I have no possibility to set in routerwhich action should be called. – acabala Feb 20 '13 at 07:48
  • Ah you never mentioned that :) – Andrew Feb 20 '13 at 08:32