I'm struggling with this problem and can't get over it.
What I want to achieve is a route like this: /rolepermission[/:roleid]/permissions[/:permissionid][/action/:action]
Currently I came up with something like this:
'rolepermission' => array(
'type' => 'literal',
'options' => array(
'route' => '/rolepermission',
'constraints' => array(),
'defaults' => array(
'controller' => 'My\Controller\RolePermission',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'rolepermissionroleid' => array(
'type' => 'segment',
'options' => array(
'route' => '/[:roleid]',
'constraints' => array(
'roleid' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'action' => 'detail',
),
),
'may_terminate' => true,
'child_routes' => array(
'rolepermissionpermissions' => array(
'type' => 'literal',
'options' => array(
'route' => '/permissions',
'constraints' => array(),
'defaults' => array(
'action' => 'index'
),
),
'may_terminate' => true,
'child_routes' => array(
'rolepermissionpermissionid' => array(
'type' => 'segment',
'options' => array(
'route' => '/[:permissionid]',
'constraints' => array(
'permissionid' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
'may_terminate' => true,
'child_routes' => array(
'rolepermissionaction' => array(
'type' => 'segment',
'options' => array(
'route' => '/action/[:action]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'action' => 'index'
),
),
'may_terminate' => false,
'child_routes' => array(),
),
),
),
),
),
),
),
),
),
When routing to /rolepermission/permissions I constantly get 'permissions' substituted for :roleid. I'm expecting here nothing to be substituted due to not passing a roleid. What am I doing wrong?
Thanks in advance, cheers
Solved the problem temporarily by adapting the 'rolepermissionpermissions' child route as following:
'rolepermission' => array(
'type' => 'segment',
'options' => array(
'route' => '/rolepermission',
'constraints' => array(),
'defaults' => array(
'controller' => 'My\Controller\RolePermission',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'rolepermissionroleid' => array(
'type' => 'segment',
'options' => array(
'route' => '/:roleid',
'constraints' => array(
'roleid' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'action' => 'detail'
),
),
'may_terminate' => true,
'child_routes' => array(
'rolepermissionpermissionid' => array(
'type' => 'segment',
'options' => array(
'route' => '[/permission/:permissionid]',
'constraints' => array(
'permissionid' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'action' => 'detail',
),
),
'may_terminate' => true,
'child_routes' => array(
'rolepermissionaction' => array(
'type' => 'segment',
'options' => array(
'route' => '/action/:action',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'action' => 'detail'
),
),
'may_terminate' => true,
'child_routes' => array(),
),
),
),
),
),
),
),
Although it's indeed not the best solution, this works for now.