/** * Returns href for this page * * This method uses {@link RouteStackInterface} to assemble * the href based on the page's properties. * * @see RouteStackInterface * @return string page href * @throws Exception\DomainException if no router is set */ public function getHref() { $url = parent::getHref(); if (!empty($this->get('locale'))) { $url = '/' . $this->get('locale') . $url; } return $url; }
public function testNoExceptionForGetHrefIfDefaultRouterIsSet() { $page = new Page\Mvc(array( 'label' => 'foo', 'action' => 'index', 'controller' => 'index', 'route' => 'default', 'defaultRouter' => $this->router )); // If the default router is not used an exception will be thrown. // This method intentionally has no assertion. $page->getHref(); $page->setDefaultRouter(null); }
public function testSpecifyingAnotherUrlHelperToGenerateHrefs() { $newHelper = new \ZendTest\Navigation\TestAsset\UrlHelper(); Page\Mvc::setUrlHelper($newHelper); $page = new Page\Mvc(); $expected = \ZendTest\Navigation\TestAsset\UrlHelper::RETURN_URL; $actual = $page->getHref(); $front = FrontController::getInstance(); $old = $front->getHelperBroker()->load('URL'); Page\Mvc::setUrlHelper($old); $this->assertEquals($expected, $actual); }
public function testSpecifyingAnotherUrlHelperToGenerateHrefs() { $newHelper = new TestAsset\UrlHelper(); $page = new Page\Mvc(); $page->setUrlHelper($newHelper); $expected = TestAsset\UrlHelper::RETURN_URL; $actual = $page->getHref(); $this->assertEquals($expected, $actual); }
public function testInheritedRouteMatchParamsWorkWithModuleRouteListener() { $page = new Page\Mvc(array('label' => 'mpinkstonwashere', 'route' => 'lmaoplane')); $route = new SegmentRoute('/lmaoplane[/:controller]'); $router = new TreeRouteStack(); $router->addRoute('lmaoplane', $route); $routeMatch = new RouteMatch(array(ModuleRouteListener::MODULE_NAMESPACE => 'Application\\Controller', 'controller' => 'index')); $routeMatch->setMatchedRouteName('lmaoplane'); $event = new MvcEvent(); $event->setRouter($router)->setRouteMatch($routeMatch); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->onRoute($event); $page->setRouter($event->getRouter()); $page->setRouteMatch($event->getRouteMatch()); $this->assertEquals('/lmaoplane', $page->getHref()); $page->setUseRouteMatch(true); $this->assertEquals('/lmaoplane/index', $page->getHref()); }