Zend Framework 2 Part Route Assembly

Viewed 6102

My Zend Framework 2 application has a route definition that's trying to mimic the default Zend Framework 1 route. It looks like:

        'router' => array(
            'routes' => array(
                'default' => array(
                    'type'    => 'segment',
                    'options' => array(
                        'route'    => '/[:controller[/:action]]',
                        'defaults' => array(
                            '__NAMESPACE__' => 'Application\Controller',
                            'controller'    => 'Index',
                            'action'        => 'index',
                        ),
                    ),
                    'may_terminate' => true,
                    'child_routes'  => array(
                        'wildcard' => array(
                            'type' => 'wildcard',
                        ),
                    ),
                ),
            ),
        ),

It matches routes just fine, but I can't assemble routes with arbitrary parameters using the Url view helper.

For example,

$this->url('default', array('controller' => 'test', 'action' => 'test', 'id' => 5));

results in /test/test instead of /test/test/id/5.

Does anyone know how to assemble partial routes like this? Or is there a better way of getting ZF1-style routes?

1 Answers
Related