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

  1. http://subdomain.exampledomain.com/route/optin
  2. 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

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -