diff --git a/src/Page/Uri.php b/src/Page/Uri.php index 7514ae7..338e937 100644 --- a/src/Page/Uri.php +++ b/src/Page/Uri.php @@ -9,7 +9,6 @@ namespace Zend\Navigation\Page; -use Zend\Http\Request; use Zend\Navigation\Exception; /** @@ -24,13 +23,6 @@ class Uri extends AbstractPage */ protected $uri = null; - /** - * Request object used to determine uri path - * - * @var string - */ - protected $request; - /** * Sets page URI * @@ -84,53 +76,6 @@ public function getHref() return $uri; } - /** - * Returns whether page should be considered active or not - * - * This method will compare the page properties against the request uri. - * - * @param bool $recursive - * [optional] whether page should be considered - * active if any child pages are active. Default is - * false. - * @return bool whether page should be considered active or not - */ - public function isActive($recursive = false) - { - if (!$this->active) { - if ($this->getRequest() instanceof Request) { - if ($this->getRequest()->getUri()->getPath() == $this->getUri()) { - $this->active = true; - return true; - } - } - } - - return parent::isActive($recursive); - } - - /** - * Get the request - * - * @return Request - */ - public function getRequest() - { - return $this->request; - } - - /** - * Sets request for assembling URLs - * - * @param Request $request - * @return Fluent interface, returns self - */ - public function setRequest(Request $request = null) - { - $this->request = $request; - return $this; - } - /** * Returns an array representation of the page * diff --git a/src/Service/AbstractNavigationFactory.php b/src/Service/AbstractNavigationFactory.php index 807d8a1..f5af421 100644 --- a/src/Service/AbstractNavigationFactory.php +++ b/src/Service/AbstractNavigationFactory.php @@ -10,7 +10,6 @@ namespace Zend\Navigation\Service; use Zend\Config; -use Zend\Http\Request; use Zend\Mvc\Router\RouteMatch; use Zend\Mvc\Router\RouteStackInterface as Router; use Zend\Navigation\Exception; @@ -80,14 +79,8 @@ protected function preparePages(ServiceLocatorInterface $serviceLocator, $pages) $application = $serviceLocator->get('Application'); $routeMatch = $application->getMvcEvent()->getRouteMatch(); $router = $application->getMvcEvent()->getRouter(); - $request = $application->getMvcEvent()->getRequest(); - // HTTP request is the only one that may be injected - if (!$request instanceof Request) { - $request = null; - } - - return $this->injectComponents($pages, $routeMatch, $router, $request); + return $this->injectComponents($pages, $routeMatch, $router); } /** @@ -121,13 +114,11 @@ protected function getPagesFromConfig($config = null) * @param array $pages * @param RouteMatch $routeMatch * @param Router $router - * @param null|Request $request * @return mixed */ - protected function injectComponents(array $pages, RouteMatch $routeMatch = null, Router $router = null, $request = null) + protected function injectComponents(array $pages, RouteMatch $routeMatch = null, Router $router = null) { foreach ($pages as &$page) { - $hasUri = isset($page['uri']); $hasMvc = isset($page['action']) || isset($page['controller']) || isset($page['route']); if ($hasMvc) { if (!isset($page['routeMatch']) && $routeMatch) { @@ -136,17 +127,12 @@ protected function injectComponents(array $pages, RouteMatch $routeMatch = null, if (!isset($page['router'])) { $page['router'] = $router; } - } elseif ($hasUri) { - if (!isset($page['request'])) { - $page['request'] = $request; - } } if (isset($page['pages'])) { - $page['pages'] = $this->injectComponents($page['pages'], $routeMatch, $router, $request); + $page['pages'] = $this->injectComponents($page['pages'], $routeMatch, $router); } } return $pages; } - } diff --git a/test/Page/UriTest.php b/test/Page/UriTest.php index f0b17b3..380d31c 100644 --- a/test/Page/UriTest.php +++ b/test/Page/UriTest.php @@ -12,7 +12,6 @@ use Zend\Navigation\Page; use Zend\Navigation; -use Zend\Http\Request; /** * Tests the class Zend_Navigation_Page_Uri @@ -91,40 +90,6 @@ public function testGetHref() $this->assertEquals($uri, $page->getHref()); } - public function testIsActiveReturnsTrueWhenHasMatchingRequestUri() - { - $page = new Page\Uri(array( - 'label' => 'foo', - 'uri' => '/bar' - )); - - $request = new Request(); - $request->setUri('/bar'); - $request->setMethod('GET'); - - $page->setRequest($request); - - $this->assertInstanceOf('Zend\Http\Request', $page->getRequest()); - - $this->assertTrue($page->isActive()); - } - - public function testIsActiveReturnsFalseOnNonMatchingRequestUri() - { - $page = new Page\Uri(array( - 'label' => 'foo', - 'uri' => '/bar' - )); - - $request = new Request(); - $request->setUri('/baz'); - $request->setMethod('GET'); - - $page->setRequest($request); - - $this->assertFalse($page->isActive()); - } - /** * @group ZF-8922 */