php - Zend2 routes constraints like enum -
i want have enum constraint on variable passed of project's route
e.g. variable routevar can optin or optout
so lets want have url http://subdomain.exampledomain.com/route/ can 1 of 2 following forms
- http://subdomain.exampledomain.com/route/optin
- http://subdomain.exampledomain.com/route/optout
the route configuration i've put shown bellow , have tried both [optin|optout] , [optin|optout]+ regexes no luck
'route-name' => [ 'type' => 'segment', 'options' => [ 'route' => '/route/:routevar', 'constraints' => [ 'routevar' => '[optin|optout]', ], 'defaults' => [ 'controller' => somecontroller::class, 'action' => 'someaction', ], ], 'may_terminate' => true, ], please note: child route , works fine address expected controller , action. fail apply the limitation described using constraint :(
the regex looking
(optin|optout) , [] syntax character groups.
actually maybe
^(optin|optout)$ to make sure there no characters in value.
Comments
Post a Comment