diff --git a/src/Routing/Router.php b/src/Routing/Router.php index d3e3ada436e..2c6e8ad69e6 100644 --- a/src/Routing/Router.php +++ b/src/Routing/Router.php @@ -971,6 +971,9 @@ public static function scope($path, $params = [], $callback = null) * For example a path of `admin` would result in `'prefix' => 'admin'` being * applied to all connected routes. * + * The prefix name will be inflected to the underscore version to create + * the routing path. If you want a custom path name, use the `path` option. + * * You can re-open a prefix as many times as necessary, as well as nest prefixes. * Nested prefixes will result in prefix values like `admin/api` which translates * to the `Controller\Admin\Api\` namespace. diff --git a/tests/TestCase/Routing/RouterTest.php b/tests/TestCase/Routing/RouterTest.php index c97cadc1a6b..55bf28cc7e5 100644 --- a/tests/TestCase/Routing/RouterTest.php +++ b/tests/TestCase/Routing/RouterTest.php @@ -3104,6 +3104,12 @@ public function testPrefixOptions() $this->assertEquals('/admin', $routes->path()); $this->assertEquals(['prefix' => 'admin', 'param' => 'value'], $routes->params()); }); + + Router::prefix('CustomPath', ['path' => '/custom-path'], function ($routes) { + $this->assertInstanceOf('Cake\Routing\RouteBuilder', $routes); + $this->assertEquals('/custom-path', $routes->path()); + $this->assertEquals(['prefix' => 'CustomPath'], $routes->params()); + }); } /**