Permalink
Browse files

Merge branch 'release'

  • Loading branch information...
2 parents 6c4b54a + 06bdec8 commit 5e547b744cb47c6ac1b00b257d2b60d80ebf127d @weierophinney weierophinney committed Sep 13, 2012
Showing with 39 additions and 0 deletions.
  1. +5 −0 library/Zend/Navigation/Page/Mvc.php
  2. +34 −0 tests/ZendTest/Navigation/Page/MvcTest.php
@@ -13,6 +13,7 @@
use Zend\Mvc\Router\RouteMatch;
use Zend\Mvc\Router\RouteStackInterface;
use Zend\Navigation\Exception;
+use Zend\Mvc\ModuleRouteListener;
use Zend\View\Helper\Url as UrlHelper;
/**
@@ -110,6 +111,10 @@ public function isActive($recursive = false)
if ($this->routeMatch instanceof RouteMatch) {
$reqParams = $this->routeMatch->getParams();
+ if (isset($reqParams[ModuleRouteListener::ORIGINAL_CONTROLLER])) {
+ $reqParams['controller'] = $reqParams[ModuleRouteListener::ORIGINAL_CONTROLLER];
+ }
+
$myParams = $this->params;
if (null !== $this->controller) {
$myParams['controller'] = $this->controller;
@@ -15,6 +15,8 @@
use Zend\Mvc\Router\Http\Regex as RegexRoute;
use Zend\Mvc\Router\Http\Literal as LiteralRoute;
use Zend\Mvc\Router\Http\TreeRouteStack;
+use Zend\Mvc\ModuleRouteListener;
+use Zend\Mvc\MvcEvent;
use Zend\Navigation\Page;
use Zend\Navigation;
use ZendTest\Navigation\TestAsset;
@@ -122,6 +124,38 @@ public function testIsActiveReturnsTrueWhenMatchingRoute()
$this->assertEquals(true, $page->isActive());
}
+ public function testIsActiveReturnsTrueWhenMatchingRouteWhileUsingModuleRouteListener()
+ {
+ $page = new Page\Mvc(array(
+ 'label' => 'mpinkstonwashere',
+ 'route' => 'roflcopter',
+ 'controller' => 'index'
+ ));
+
+ $route = new LiteralRoute('/roflcopter');
+
+ $router = new TreeRouteStack;
+ $router->addRoute('roflcopter', $route);
+
+ $routeMatch = new RouteMatch(array(
+ ModuleRouteListener::MODULE_NAMESPACE => 'Application\Controller',
+ 'controller' => 'index'
+ ));
+ $routeMatch->setMatchedRouteName('roflcopter');
+
+ $event = new MvcEvent();
+ $event->setRouter($router)
+ ->setRouteMatch($routeMatch);
+
+ $moduleRouteListener = new ModuleRouteListener();
+ $moduleRouteListener->onRoute($event);
+
+ $page->setRouter($event->getRouter());
+ $page->setRouteMatch($event->getRouteMatch());
+
+ $this->assertEquals(true, $page->isActive());
+ }
+
public function testIsActiveReturnsFalseWhenMatchingRouteButNonMatchingParams()
{
$page = new Page\Mvc(array(

0 comments on commit 5e547b7

Please sign in to comment.