ZF-6404: Minor improvement to Zend_Controller_Router_Route_* classes to make them suitable for using in Zend_Controller_Router_Route_Chain


Currently (version 1.8) it's impossible to use assemble when using route Chain without side-effects. Chain's assemble method checks what variables each chain node injected into assembled url:

    public function assemble($data = array(), $reset = false, $encode = false)
        $value = '';

        foreach ($this->_routes as $key => $route) {
            if ($key > 0) {
                $value .= $this->_separators[$key];

            $value .= $route->assemble($data, $reset, $encode);
// Check begins here vvvvv
            if (method_exists($route, 'getVariables')) {
                $variables = $route->getVariables();

                foreach ($variables as $variable) {
                    $data[$variable] = null;

        return $value;

Note for getVariables method. Everything seemed to be great for now BUT only Hostname route seemed to implement this method so when we trying to chain few Zend_Controller_Router_Route objects together with last of them having '*' in pattern, or chaining Zend_Controller_Router_Route with Zend_Controller_Router_Module we have all of our params wich was already in url from first Route elements doubled by the last one:

        $lngRoute = new Zend_Controller_Router_Route(
                'language'      =>  'none',
                'language'      =>  '[a-z]{2}'
// App_Controller_Router_Route_Module -- workaroud to ZF-6399
        $route_module = new App_Controller_Router_Route_Module(

        $chain = new Zend_Controller_Router_Route_Chain();
        $router->addRoute('default', $chain);


        $router->assemble(array('language' => 'en', 'module' => 'user', 'controller' => 'register', 'action' => 'action'));
// EXPECTED: /en/user/register/action
// CURRENT OUTPUT: /en/user/register/action/language/en

That happens because Zend_Controller_Router_Route DO NOT define getVariables method.

so it seemed to me that all Rute_* classes should be reworked with getVariables method added (more of it: it would be great to add this method to Abstract Route class).


Assigning to dasprid