routes.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * Routes configuration
  4. *
  5. * In this file, you set up routes to your controllers and their actions.
  6. * Routes are very important mechanism that allows you to freely connect
  7. * different URLs to chosen controllers and their actions (functions).
  8. *
  9. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  10. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. *
  12. * Licensed under The MIT License
  13. * For full copyright and license information, please see the LICENSE.txt
  14. * Redistributions of files must retain the above copyright notice.
  15. *
  16. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  17. * @link http://cakephp.org CakePHP(tm) Project
  18. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  19. */
  20. use Cake\Core\Plugin;
  21. use Cake\Routing\RouteBuilder;
  22. use Cake\Routing\Router;
  23. use Cake\Core\Configure;
  24. /**
  25. * The default class to use for all routes
  26. *
  27. * The following route classes are supplied with CakePHP and are appropriate
  28. * to set as the default:
  29. *
  30. * - Route
  31. * - InflectedRoute
  32. * - DashedRoute
  33. *
  34. * If no call is made to `Router::defaultRouteClass()`, the class used is
  35. * `Route` (`Cake\Routing\Route\Route`)
  36. *
  37. * Note that `Route` does not do any inflections on URLs which will result in
  38. * inconsistently cased URLs when used with `:plugin`, `:controller` and
  39. * `:action` markers.
  40. *
  41. */
  42. Router::defaultRouteClass('DashedRoute');
  43. Router::scope('/', function (RouteBuilder $routes) {
  44. /**
  45. * Here, we are connecting '/' (base path) to a controller called 'Pages',
  46. * its action called 'display', and we pass a param to select the view file
  47. * to use (in this case, src/Template/Pages/home.ctp)...
  48. */
  49. $routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
  50. /**
  51. * ...and connect the rest of 'Pages' controller's URLs.
  52. */
  53. $routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
  54. $routes->connect('/repo/*', ['controller' => 'AddonVersions', 'action' => 'updateRepository']);
  55. $routes->connect('/submit', ['controller' => 'AddonVersions', 'action' => 'upload']);
  56. $routes->connect(
  57. '/oauth/:provider',
  58. ['controller' => 'users', 'action' => 'login'],
  59. ['provider' => implode('|', array_keys(Configure::read('Muffin/OAuth2.providers')))]
  60. );
  61. /**
  62. * Connect catchall routes for all controllers.
  63. *
  64. * Using the argument `DashedRoute`, the `fallbacks` method is a shortcut for
  65. * `$routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'DashedRoute']);`
  66. * `$routes->connect('/:controller/:action/*', [], ['routeClass' => 'DashedRoute']);`
  67. *
  68. * Any route class can be used with this method, such as:
  69. * - DashedRoute
  70. * - InflectedRoute
  71. * - Route
  72. * - Or your own route class
  73. *
  74. * You can remove these routes once you've connected the
  75. * routes you want in your application.
  76. */
  77. $routes->fallbacks('DashedRoute');
  78. });
  79. /**
  80. * Load all plugin routes. See the Plugin documentation on
  81. * how to customize the loading of plugin routes.
  82. */
  83. Plugin::routes();