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

Issue Type: Improvement Created: 2009-04-23T22:17:54.000+0000 Last Updated: 2009-04-26T15:01:48.000+0000 Status: Resolved Fix version(s): - 1.8.0 (30/Apr/09)

Reporter: Anjey Lobas (anjey) Assignee: Ben Scholzen (dasprid) Tags: - Zend_Controller

Related issues: Attachments:


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:

<pre class="highlight">
    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:

<pre class="highlight">
        $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).


Posted by Matthew Weier O'Phinney (matthew) on 2009-04-24T06:04:22.000+0000

Assigning to dasprid

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.