Skip to content

Commit

Permalink
Organize and align routes
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner committed Oct 10, 2019
1 parent c2407a1 commit 70af876
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions user_guide_src/source/incoming/restful.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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::

Expand Down

0 comments on commit 70af876

Please sign in to comment.