public function getUrl($forceCanonical = false) { $parent = $this->getParent(); $path = $this->getUrlKey(); if (!empty($parent)) { $path = $parent->getUrl() . '/' . $path; } $url = '/' . ltrim($path, '/'); if ($forceCanonical) { $serverUrl = Registry::get('Application')->getServiceManager()->get('ViewHelperManager')->get('ServerUrl'); $url = $serverUrl() . $url; } return $url; }
/** * Test * * @return void */ public function testGetUrl() { $this->assertEquals('/parent/url-key', $this->object->getUrl()); $this->assertEquals('http:///parent/url-key', $this->object->getUrl(true)); }