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

Commit

Permalink
Merge branch 'hotfix/4634'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Jun 12, 2013
153 parents 090f966 + f51e1ec + e6b286e + d5c10b6 + 0eabc04 + fed2583 + af2d845 + e8e4ce2 + f4be937 + 9323faa + 65deb5a + d5a4f17 + 94b36e8 + 62824a2 + 6378cbe + a10281c + cd0ff39 + 02e8122 + a667dd4 + 02ccc35 + 7d61487 + ab2f663 + a27ca10 + 75af0e5 + 24f498b + d2dd157 + 6c759d8 + 51b0320 + aabe1c0 + e76b67c + 5d85a78 + d285b08 + c5df6b0 + ff58ff4 + 5675884 + a55ead5 + 47eb5a8 + a36e34a + 3e520ad + 7b0d374 + 461c28b + 3890e69 + 316384e + 1431343 + debad5a + 1680741 + 4497a00 + bb6633a + 6b7ed03 + 35fcae3 + 0737e9d + c31bf4c + 918649e + ecbe771 + b4124fc + f4e1da0 + a8c70a8 + 50d3c5d + 79180fa + f6f9386 + 8ed6590 + d79a4a4 + 3958052 + eae6146 + 1cc7a46 + 1d9542f + a22d6e2 + 3496b67 + 9398e77 + 687d980 + 900dc7d + 21f6363 + 0eeb6ff + 8c442a3 + adf1f8e + c2ceb18 + 9b17a1c + d5dab4a + 346a62a + 9808633 + bdeec54 + 1a2506a + f5f3d02 + b623064 + 4338bf4 + bdababf + 4054000 + 4449c16 + d3d8b33 + 8427cf8 + 8d162ec + a988e9a + 3e9d597 + ee93c08 + 9d3ce53 + f04a59c + 0c3f2de + a654383 + 502d937 + 93350ca + 23a0ccc + 15dc071 + 6ca79e9 + 7645850 + 7b0843e + b9f38cc + 53d4205 + 0ba91ba + 7ad75c4 + 35376fd + e6713be + b15c871 + 4121ed2 + 905626d + 529973a + e28e80a + b64275a + 2f43075 + 05dea5f + b0f56ea + a0ae2ac + 8b01bd8 + fc7acfc + 87b1ffc + c00475b + 6d05c34 + 2f2787b + 229c668 + c164e00 + e5c1ff6 + 5023ed3 + 3c689b8 + 789b92c + ae927c2 + 7741eac + ab3bdcd + 6c02989 + 0d17da2 + 1035d13 + 361c1cf + b31816b + 0102405 + 84330e4 + 50b28a7 + 196892e + 55ecf0a + cdf2159 + 97a5f0f + 2951d73 + bbfc15c + 7aff06a + 2ec87c8 + 6a4d652 commit 9fd7105
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Page/Mvc.php
Expand Up @@ -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;
}
}

Expand Down
69 changes: 69 additions & 0 deletions test/Page/MvcTest.php
Expand Up @@ -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));

}
}

0 comments on commit 9fd7105

Please sign in to comment.