Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Zend\Navigation\Page\Mvc::getHref now utilizes RouteMatch parameters …
Browse files Browse the repository at this point in the history
…when they are available
  • Loading branch information
Adam Lundrigan committed Mar 21, 2013
1 parent e00aefc commit caf8e58
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
7 changes: 6 additions & 1 deletion library/Zend/Navigation/Page/Mvc.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ public function getHref()
);
}

$params = $this->getParams();
if ($this->getRouteMatch() !== null) {
$params = array_merge($this->getRouteMatch()->getParams(), $this->getParams());
} else {
$params = $this->getParams();
}


if (($param = $this->getController()) != null) {
$params['controller'] = $param;
Expand Down
26 changes: 26 additions & 0 deletions tests/ZendTest/Navigation/Page/MvcTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Zend\Mvc\Router\RouteMatch;
use Zend\Mvc\Router\Http\Regex as RegexRoute;
use Zend\Mvc\Router\Http\Literal as LiteralRoute;
use Zend\Mvc\Router\Http\Segment as SegmentRoute;
use Zend\Mvc\Router\Http\TreeRouteStack;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
Expand Down Expand Up @@ -498,4 +499,29 @@ public function testNoExceptionForGetHrefIfDefaultRouterIsSet()
$page->getHref();
$page->setDefaultRouter(null);
}

public function testMvcPageParamsInheritRouteMatchParams()
{
$page = new Page\Mvc(array(
'label' => 'lollerblades',
'route' => 'lollerblades'
));

$route = new SegmentRoute('/lollerblades/view/:serialNumber');

$router = new TreeRouteStack;
$router->addRoute('lollerblades', $route);

$routeMatch = new RouteMatch(array(
'serialNumber' => 23,
));
$routeMatch->setMatchedRouteName('lollerblades');

$page->setRouter($router);
$page->setRouteMatch($routeMatch);

$this->assertEquals('/lollerblades/view/23', $page->getHref());
}


}

0 comments on commit caf8e58

Please sign in to comment.