Is it possible in ZF2 routing to have a generic parent route, matching all public actions, but override specific areas with a custom child-route and controller?
What I want:
/parent => matches parent controller
/parent/edit => matches parent controller editAction
/parent/childsection => matches child controller
/parent/childsection/edit => matches child controller editAction
I couldn't come up with any configuration that fits my needs. Following the config I thought would work - but ZF2 routes terminates at the parent route cause childsection
could be an action too.
'parent' => array(
'type' => 'Segment',
'may_terminate' => true,
'options' => array(
'route' => '/parent[[/:action][/:id]]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Application\Controller\Parent',
'action' => 'index',
),
),
'child_routes' => array(
'child' => array(
'type' => 'Segment',
'options' => array(
'route' => '/childsection/:action[/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Application\Controller\Child',
),
),
),
),
),
The only thing that worked was a minimal parent literal route and 2 child routes - 1 generic and 1 specific for the child section. But in this case I have to redirect or generate urls using ->toRoute('parent/default'...)
Is there any other elegant solution or is this simply not possible?