From c9f348081a62e6b4752faf303f22b91eae9472b4 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 24 Jul 2017 22:29:42 -0400 Subject: [PATCH] Update 3.5 migration guide for routebuilder. Add deprecations added in cakephp/cakephp#10943 --- en/appendices/3-5-migration-guide.rst | 3 +++ en/development/routing.rst | 17 +++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/en/appendices/3-5-migration-guide.rst b/en/appendices/3-5-migration-guide.rst index f26da57ffb..d2b47b2c60 100644 --- a/en/appendices/3-5-migration-guide.rst +++ b/en/appendices/3-5-migration-guide.rst @@ -75,6 +75,9 @@ The following is a list of methods that are deprecated and replaced with ``setInvalidField()``, and ``getInvalidField()``) ``Cake\ORM\Table`` * ``validator()`` +``Cake\Routing\RouteBuilder`` + * ``extensions()`` + * ``routeClass()`` ``Cake\Routing\RouteCollection`` * ``extensions()`` ``Cake\TestSuite\TestFixture`` diff --git a/en/development/routing.rst b/en/development/routing.rst index 6898ffe716..1f47562156 100644 --- a/en/development/routing.rst +++ b/en/development/routing.rst @@ -298,7 +298,7 @@ rewritten like so:: // Create a builder with a different route class. $routes->scope('/', function ($routes) { - $routes->routeClass(DashedRoute::class); + $routes->setRouteClass(DashedRoute::class); $routes->connect('/:controller/:id', ['action' => 'view']) ->setPatterns(['id' => '[0-9]+']); @@ -830,15 +830,15 @@ This will affect **all** routes that are being connected **afterwards**, no matt their scope. In order to restrict extensions to specific scopes, you can define them using the -:php:meth:`Cake\\Routing\\RouteBuilder::extensions()` method:: +:php:meth:`Cake\\Routing\\RouteBuilder::setExtensions()` method:: Router::scope('/', function ($routes) { - $routes->extensions(['json', 'xml']); - // ... + // Prior to 3.5.0 use `extensions()` + $routes->setExtensions(['json', 'xml']); }); This will enable the named extensions for all routes that are being connected in -that scope **after** the ``extensions()`` call, including those that are being +that scope **after** the ``setExtensions()`` call, including those that are being connected in nested scopes. Similar to the global :php:meth:`Router::extensions()` method, any routes connected prior to the call will not inherit the extensions. @@ -856,7 +856,7 @@ and then parse what remains. If you want to create a URL such as /page/title-of-page.html you would create your route using:: Router::scope('/page', function ($routes) { - $routes->extensions(['json', 'xml', 'html']); + $routes->setExtensions(['json', 'xml', 'html']); $routes->connect( '/:title', ['controller' => 'Pages', 'action' => 'view'] @@ -962,7 +962,7 @@ this:: // In config/routes.php... Router::scope('/', function ($routes) { - $routes->extensions(['json']); + $routes->setExtensions(['json']); $routes->resources('Recipes'); }); @@ -1349,7 +1349,8 @@ option:: // Or by setting the routeClass in your scope. $routes->scope('/', function ($routes) { - $routes->routeClass('SlugRoute'); + //Prior to 3.5.0 use `routeClass()` + $routes->setRouteClass('SlugRoute'); $routes->connect( '/:slug', ['controller' => 'Articles', 'action' => 'view']