From 81c79c3f9cab1332ebd48f503d948b6dadda3b7f Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 10 Apr 2017 21:56:19 -0400 Subject: [PATCH] Add docs for new routebuilder option. --- en/appendices/3-5-migration-guide.rst | 3 +++ en/development/routing.rst | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/en/appendices/3-5-migration-guide.rst b/en/appendices/3-5-migration-guide.rst index a7d74a5c9a..52f4fab67c 100644 --- a/en/appendices/3-5-migration-guide.rst +++ b/en/appendices/3-5-migration-guide.rst @@ -41,6 +41,9 @@ New Features * ``Cake\Routing\Router::reverseToArray()`` was added. This method allow you to convert a request object into an array that can be used to generate URL strings. +* ``Cake\Routing\RouteBuilder::resources()`` had the ``path`` option + added. This option lets you make the resource path and controller name not + match. * New abstract types were added for ``smallinteger`` and ``tinyinteger``. Existing ``SMALLINT`` and ``TINYINT`` columns will now be reflected as these new abstract types. ``TINYINT(1)`` columns will continue to be treated as diff --git a/en/development/routing.rst b/en/development/routing.rst index cdbbc08a96..c1dc6df76b 100644 --- a/en/development/routing.rst +++ b/en/development/routing.rst @@ -942,7 +942,7 @@ You can specify an alternative inflection type using the ``inflect`` option:: ]); }); -The above will generate URLs styled like: **/blog-posts/\***. +The above will generate URLs styled like: **/blog-posts**. .. note:: @@ -950,6 +950,19 @@ The above will generate URLs styled like: **/blog-posts/\***. default route class. Using the ``'inflect' => 'dasherize'`` option when connecting resource routes is recommended for URL consistency. +Changing the Path Element +------------------------- + +By default resource routes use an inflected form of the resource name for the +URL segment. You can set a custom URL segment with the ``path`` option:: + + Router::scope('/', function ($routes) { + $routes->resources('BlogPosts', ['path' => 'posts']); + }); + +.. versionadded:: 3.5.0 + The ``path`` option was added in 3.5.0 + .. index:: passed arguments .. _passed-arguments: