Issues

ZF-11261: Zend_Navigation url generation with routes doesn't take default route into consideration

Description

Zend_Navigation_Page_Mvc method getRoute() doesn't take a default route into consideration.

When URLs are constructed using the URL helper, the second parameter must be a route name or null. When using a route and viewing a page all helper constructed URLs must use 'default' as the route parameter. However, the Zend_Navigation_Page_Mvc component doesn't take this into consideration. Either all pages in the navigation configuration must define the (in xml form) as default or, the getRoute() method must return the following:

return (is_null($this->_route)) ? 'default' : $this->_route;

This takes a null route and turns it into the default route.

Comments

This is not a bug, this is the normal behaviour!


public function assemble($userParams, $name = null, $reset = false, $encode = true)
{
    if ($name == null) {
        try {
            $name = $this->getCurrentRouteName();
        } catch (Zend_Controller_Router_Exception $e) {
            $name = 'default';
        }
    }

    // …
}

[http://framework.zend.com/code/filedetails.php/…]

  • "null" means: use the current active route
  • "default" means: use the actual route instance with the name 'default'

Zend_Navigation uses the action helper and router as documented. It is not the task of Zend_Navigation to build a url or to change the behaviour from Zend_Controller_Router.