Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Navigation\Page\Mvc Can't return false whithout call parent::isActive #4634

Closed
wants to merge 1 commit into from

2 participants

gag237 Matthew Weier O'Phinney
gag237

Sorry, my previous commit #4628, introduced this bug.

Matthew Weier O'Phinney

I cherry-picked this into master when merging as it applies there.

Deleted user Unknown referenced this pull request from a commit
Matthew Weier O'Phinney weierophinney Merge branch 'hotfix/4634'
Close #4634
c818e5c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 12, 2013
  1. gag237
This page is out of date. Refresh to see the latest.
6 library/Zend/Navigation/Page/Mvc.php
View
@@ -132,15 +132,15 @@ public function isActive($recursive = false)
}
if (null !== $this->getRoute()) {
- $this->active = false;
if (
$this->routeMatch->getMatchedRouteName() === $this->getRoute()
&& (count(array_intersect_assoc($reqParams, $myParams)) == count($myParams))
) {
$this->active = true;
+ return $this->active;
+ } else {
+ return parent::isActive($recursive);
}
-
- return $this->active;
}
}
69 tests/ZendTest/Navigation/Page/MvcTest.php
View
@@ -667,4 +667,73 @@ public function testMistakeDetectIsActiveOnIndexController()
$this->assertFalse($page->isActive());
}
+
+ public function testRecursiveDetectIsActiveWhenRouteNameIsKnown()
+ {
+ $parentPage = new Page\Mvc(
+ array(
+ 'label' => 'some Label',
+ 'route' => 'parentPageRoute',
+ )
+ );
+ $childPage = new Page\Mvc(
+ array(
+ 'label' => 'child',
+ 'route' => 'childPageRoute',
+ )
+ );
+ $parentPage->addPage($childPage);
+
+ $router = new TreeRouteStack;
+ $router->addRoutes(
+ array(
+ 'parentPageRoute' => array(
+ 'type' => 'literal',
+ 'options' => array(
+ 'route' => '/foo',
+ 'defaults' => array(
+ 'controller' => 'fooController',
+ 'action' => 'fooAction'
+ )
+ )
+ ),
+ 'childPageRoute' => array(
+ 'type' => 'literal',
+ 'options' => array(
+ 'route' => '/bar',
+ 'defaults' => array(
+ 'controller' => 'barController',
+ 'action' => 'barAction'
+ )
+ )
+ )
+ )
+ );
+
+ $routeMatch = new RouteMatch(
+ array(
+ ModuleRouteListener::MODULE_NAMESPACE => 'Application\Controller',
+ 'controller' => 'barController',
+ 'action' => 'barAction'
+ )
+ );
+ $routeMatch->setMatchedRouteName('childPageRoute');
+
+ $event = new MvcEvent();
+ $event->setRouter($router)
+ ->setRouteMatch($routeMatch);
+
+ $moduleRouteListener = new ModuleRouteListener();
+ $moduleRouteListener->onRoute($event);
+
+ $parentPage->setRouter($event->getRouter());
+ $parentPage->setRouteMatch($event->getRouteMatch());
+
+ $childPage->setRouter($event->getRouter());
+ $childPage->setRouteMatch($event->getRouteMatch());
+
+ $this->assertTrue($childPage->isActive(true));
+ $this->assertTrue($parentPage->isActive(true));
+
+ }
}
Something went wrong with that request. Please try again.