Question

Is there a way to set up a route in ZF2 (Segment or otherwise) so that /staff/list translates to the staffListAction() action in my controller?

Typically /staff-list translates to staffListAction. Is there a way to change that delimiter?

I saw this on Evan Coury's blog, but it talks about a segment, not exactly an action.

Changing segment delimeter

Was it helpful?

Solution

This pretty much would be a route of type literal. Something like

'staff' => array(
    'type' => 'literal',
    'options' => array(
        'route' => '/staff',
        'defaults' => array(
            'controller' => 'namespace-controller-staff',
            'action' => 'index'
        )
    ),
    'may_terminate' => true,
    'child_routes' => array(
        'list' => array(
            'type' => 'literal',
            'options' => array(
                'route' => '/list',
                'defaults' => array(
                    'action' => 'staffList'
                )
            )
        )
    )
),

Didn't try it, but i assume it works. Personally i run with literal routes as much as possible, as they are the fastest to match.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top