2

I have quite a complex routing file at the moment. I want to be able to have skippable segments (which I'm using a plugin for at the moment - https://github.com/tccltd/TccSkippableSegment) but also skip that segment if it matches one of the child routes. Here's a section of the file:

return array(
'router' => array(
    'routes' => array(
        'home' => array(
            'type' => '\Application\Utilities\SkippableSegment',
            'options' => array(
                'route' => '/college/courses[/:level-name][/]',
                'constraints' => array(
                    'level-name' => '(?i:[a-zA-Z][a-zA-Z0-9_-]*)',
                ),
                'defaults' => array(
                    'controller' => 'Application\Controller\Index',
                    'action' => 'index',
                    'level-name' => '',
                ),
                'skippable' => [
                    'level-name' => true,
                ]
            ),
            'may_terminate' => true,
            'child_routes' => array(
                'privacy' => array(
                    'type' => 'Zend\Mvc\Router\Http\Literal',
                    'options' => array(
                        'route' => 'privacy-policy',
                        'defaults' => array(
                            'controller' => 'Application\Controller\Index',
                            'action' => 'privacy',
                        ),
                    ),
                ),
            ),
        ),
    ),
),

What I want to achieve is:

  • /college/courses/AS2 - Works
  • /college/courses/AS2/privacy - Works
  • /college/courses/privacy - Does not work because it thinks that 'privacy' is a level

My question is since 'privacy' is already a child node is there a way in constraints to 'ignore' it?

Any help appreciated, feel free to ask for more information if needed.

sjhuda
  • 63
  • 1
  • 7

0 Answers0