diff --git a/Slim/Router.php b/Slim/Router.php index 491727024..fda948943 100644 --- a/Slim/Router.php +++ b/Slim/Router.php @@ -111,6 +111,16 @@ public function setBasePath($basePath) return $this; } + /** + * Get the base path used in pathFor() + * + * @return string + */ + public function getBasePath() + { + return $this->basePath; + } + /** * Set path to fast route cache file. If this is false then route caching is disabled. * diff --git a/tests/RouterTest.php b/tests/RouterTest.php index 228e36bcf..e340dcb88 100644 --- a/tests/RouterTest.php +++ b/tests/RouterTest.php @@ -86,6 +86,12 @@ public function testRelativePathFor() ); } + public function testGetBasePath() + { + $this->router->setBasePath('/new/base/path'); + $this->assertEquals('/new/base/path', $this->router->getBasePath()); + } + public function testPathForWithNoBasePath() { $this->router->setBasePath('');