From 70af8762a588a4cf0c797d0aa81612b6cef1c985 Mon Sep 17 00:00:00 2001 From: MGatner Date: Thu, 10 Oct 2019 11:45:06 -0400 Subject: [PATCH] Organize and align routes --- user_guide_src/source/incoming/restful.rst | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/user_guide_src/source/incoming/restful.rst b/user_guide_src/source/incoming/restful.rst index 829958f5356c..4384198894ab 100644 --- a/user_guide_src/source/incoming/restful.rst +++ b/user_guide_src/source/incoming/restful.rst @@ -33,14 +33,14 @@ name:: $routes->resource('photos'); // Equivalent to the following: - $routes->get('photos', 'Photos::index'); $routes->get('photos/new', 'Photos::new'); - $routes->get('photos/(:segment)/edit', 'Photos::edit/$1'); - $routes->get('photos/(:segment)', 'Photos::show/$1'); $routes->post('photos', 'Photos::create'); - $routes->delete('photos/(:segment)', 'Photos::delete/$1'); - $routes->patch('photos/(:segment)', 'Photos::update/$1'); + $routes->get('photos', 'Photos::index'); + $routes->get('photos/(:segment)', 'Photos::show/$1'); + $routes->get('photos/(:segment)/edit', 'Photos::edit/$1'); $routes->put('photos/(:segment)', 'Photos::update/$1'); + $routes->patch('photos/(:segment)', 'Photos::update/$1'); + $routes->delete('photos/(:segment)', 'Photos::delete/$1'); .. important:: The routes are matched in the order they are specified, so if you have a resource photos above a get 'photos/poll' the show action's route for the resource line will be matched before the get line. To fix this, move the get line above the resource line so that it is matched first. @@ -138,17 +138,17 @@ Its usage is similar to the resosurce routing:: $routes->presenter('photos'); // Equivalent to the following: - $routes->get('photos', 'Photos::index'); - $routes->post('photos', 'Photos::create'); // alias - $routes->get('photos/show/(:segment)', 'Photos::show/$1'); - $routes->get('photos/new', 'Photos::new'); - $routes->post('photos/create', 'Photos::create'); - $routes->get('photos/edit/(:segment)', 'Photos::edit/$1'); - $routes->post('photos/update/(:segment)', 'Photos::update/$1'); - $routes->get('photos/remove/(:segment)', 'Photos::remove/$1'); - $routes->post('photos/delete/(:segment)', 'Photos::update/$1'); - $routes->get('photos/(:segment)', 'Photos::show/$1'); // alias - + $routes->get('photos/new', 'Photos::new'); + $routes->post('photos/create', 'Photos::create'); + $routes->post('photos', 'Photos::create'); // alias + $routes->get('photos', 'Photos::index'); + $routes->get('photos/show/(:segment)', 'Photos::show/$1'); + $routes->get('photos/(:segment)', 'Photos::show/$1'); // alias + $routes->get('photos/edit/(:segment)', 'Photos::edit/$1'); + $routes->post('photos/update/(:segment)', 'Photos::update/$1'); + $routes->get('photos/remove/(:segment)', 'Photos::remove/$1'); + $routes->post('photos/delete/(:segment)', 'Photos::update/$1'); + You would not have routes for `photos` for both a resource and a presenter controller. You need to distinguish them, for instance::