ZF-8438: Route params patch for Zend_Navigation_Page_Mvc


When I make my root navigation, it makes my links filled with all params as module, controller action.


route: profile/* > should render link Profile

but instead it renders: Profile

I made following additions and changes to. Zend/Navigation/Page/Mvc.php

I added variable:

public static $router = null;

And the get method for router:

public static function getRouter()
  if (null === self::$router) {
    self::$router = Zend_Controller_Front::getInstance()->getRouter();

  return self::$router;

Then I added some route checking to end of method getHref():

$router = self::getRouter();
if ($router->hasRoute($this->getRoute()))
  $route = $router->getRoute($this->getRoute());
  // gets route defaults and compares it to given params, then
  // returns only the ones are not found from route defaults        
  $params = array_diff($params, $route->getDefaults());
$url = self::$_urlHelper->url($params,$this->getRoute(),$this->getResetParams());

return $this->_hrefCache = $url;

br, Marko


Added code tags