Base for a static organization website

routes.php 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP(tm) Project
  12. * @package Cake.Config
  13. * @since CakePHP(tm) v 2.0
  14. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  15. */
  16. /**
  17. * Connects the default, built-in routes, including prefix and plugin routes. The following routes are created
  18. * in the order below:
  19. *
  20. * For each of the Routing.prefixes the following routes are created. Routes containing `:plugin` are only
  21. * created when your application has one or more plugins.
  22. *
  23. * - `/:prefix/:plugin` a plugin shortcut route.
  24. * - `/:prefix/:plugin/:controller`
  25. * - `/:prefix/:plugin/:controller/:action/*`
  26. * - `/:prefix/:controller`
  27. * - `/:prefix/:controller/:action/*`
  28. *
  29. * If plugins are found in your application the following routes are created:
  30. *
  31. * - `/:plugin` a plugin shortcut route.
  32. * - `/:plugin/:controller`
  33. * - `/:plugin/:controller/:action/*`
  34. *
  35. * And lastly the following catch-all routes are connected.
  36. *
  37. * - `/:controller'
  38. * - `/:controller/:action/*'
  39. *
  40. * You can disable the connection of default routes by deleting the require inside APP/Config/routes.php.
  41. */
  42. $prefixes = Router::prefixes();
  43. if ($plugins = CakePlugin::loaded()) {
  44. App::uses('PluginShortRoute', 'Routing/Route');
  45. foreach ($plugins as $key => $value) {
  46. $plugins[$key] = Inflector::underscore($value);
  47. }
  48. $pluginPattern = implode('|', $plugins);
  49. $match = array('plugin' => $pluginPattern, 'defaultRoute' => true);
  50. $shortParams = array('routeClass' => 'PluginShortRoute', 'plugin' => $pluginPattern, 'defaultRoute' => true);
  51. foreach ($prefixes as $prefix) {
  52. $params = array('prefix' => $prefix, $prefix => true);
  53. $indexParams = $params + array('action' => 'index');
  54. Router::connect("/{$prefix}/:plugin", $indexParams, $shortParams);
  55. Router::connect("/{$prefix}/:plugin/:controller", $indexParams, $match);
  56. Router::connect("/{$prefix}/:plugin/:controller/:action/*", $params, $match);
  57. }
  58. Router::connect('/:plugin', array('action' => 'index'), $shortParams);
  59. Router::connect('/:plugin/:controller', array('action' => 'index'), $match);
  60. Router::connect('/:plugin/:controller/:action/*', array(), $match);
  61. }
  62. foreach ($prefixes as $prefix) {
  63. $params = array('prefix' => $prefix, $prefix => true);
  64. $indexParams = $params + array('action' => 'index');
  65. Router::connect("/{$prefix}/:controller", $indexParams, array('defaultRoute' => true));
  66. Router::connect("/{$prefix}/:controller/:action/*", $params, array('defaultRoute' => true));
  67. }
  68. Router::connect('/:controller', array('action' => 'index'), array('defaultRoute' => true));
  69. Router::connect('/:controller/:action/*', array(), array('defaultRoute' => true));
  70. $namedConfig = Router::namedConfig();
  71. if ($namedConfig['rules'] === false) {
  72. Router::connectNamed(true);
  73. }
  74. unset($namedConfig, $params, $indexParams, $prefix, $prefixes, $shortParams, $match,
  75. $pluginPattern, $plugins, $key, $value);